Page 1 of 2

Windows check-certificate Unknown command(s) showing

Posted: Tue Sep 10, 2019 2:15 am
by grayloglearn
Hi Team,

I want to monitor the windows server certificate monitoring using nagios. I have downloaded the check_certificate plugin and executed in server which looks working fine. Find the attachment for output while executed the script.

But when we are calling the same script we are not getting command error from nagios server. The below are the configuration from nagios server end.

define command {
command_name check_nrpe_Certificate
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -u -t 90 -c $ARG1$
}

root@ip-xxxxx:/usr/local/nagios/libexec# ./check_nrpe -H 172.31.89.249 -t 90 -c Check-Certificate
Unknown command(s): check-certificate

We have added some details in nsclient.in as follows below and we copy the script in nsclint++/script/

[/settings/external scripts/]
PSCheckCertificate=cmd /c echo scripts\Check-Certificate.ps1; exit($lastexitcode) | powershell.exe -command -

Please suggest where we are doing mistake.

Re: Windows check-certificate Unknown command(s) showing

Posted: Tue Sep 10, 2019 10:00 am
by mcapra
grayloglearn wrote: [/settings/external scripts/]
PSCheckCertificate=cmd /c echo scripts\Check-Certificate.ps1; exit($lastexitcode) | powershell.exe -command -
In your nsclient.ini, you've named the command PSCheckCertificate. That is what you should be passing as the command name -c via check_nrpe:

Code: Select all

#check_nrpe -H 172.31.89.249 -t 90 -c PSCheckCertificate
More info:
https://docs.nsclient.org/howto/external_scripts/

Re: Windows check-certificate Unknown command(s) showing

Posted: Tue Sep 10, 2019 12:31 pm
by scottwilkerson
Thanks @mcapra

Re: Windows check-certificate Unknown command(s) showing

Posted: Wed Sep 11, 2019 11:42 pm
by grayloglearn
Hi team,

We have tried with the below but still we are getting same error.
root@ip-xxxx:/usr/local/nagios/libexec# ./check_nrpe -H 172.31.89.249 -t 90 -c PSCheckCertificate
Unknown command(s): pscheckcertificate

Re: Windows check-certificate Unknown command(s) showing

Posted: Thu Sep 12, 2019 7:14 am
by scottwilkerson
grayloglearn wrote:Hi team,

We have tried with the below but still we are getting same error.
root@ip-xxxx:/usr/local/nagios/libexec# ./check_nrpe -H 172.31.89.249 -t 90 -c PSCheckCertificate
Unknown command(s): pscheckcertificate
Can you share your nsclient.ini from 172.31.89.249?

Thanks

Re: Windows check-certificate Unknown command(s) showing

Posted: Fri Sep 13, 2019 1:53 am
by grayloglearn
Hi Team
Please find the attachment for nsclient.ini

Re: Windows check-certificate Unknown command(s) showing

Posted: Fri Sep 13, 2019 6:46 am
by scottwilkerson
Did you restart the NSClient++ service after adding the PSCheckCertificate command?

Re: Windows check-certificate Unknown command(s) showing

Posted: Fri Sep 13, 2019 1:30 pm
by grayloglearn
Yes I have restarted multiple times..

Re: Windows check-certificate Unknown command(s) showing

Posted: Fri Sep 13, 2019 1:34 pm
by scottwilkerson
I guess next we need to look in the nsclient.log to see what errors are in there

Re: Windows check-certificate Unknown command(s) showing

Posted: Fri Sep 13, 2019 1:36 pm
by scottwilkerson
Oh I just noticed this in your nsclient.ini file
this

Code: Select all

[/settings/external scripts/]
PSCheckCertificate=cmd /c echo scripts\Check-Certificate.ps1; exit($lastexitcode) | powershell.exe -command -
should be this

Code: Select all

[/settings/external scripts/scripts]
PSCheckCertificate=cmd /c echo scripts\Check-Certificate.ps1; exit($lastexitcode) | powershell.exe -command -
Then restart nsclient++