Windows check-certificate Unknown command(s) showing

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

Windows check-certificate Unknown command(s) showing

Post 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.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

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

Post 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/
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

Thanks @mcapra
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post by grayloglearn »

Hi Team
Please find the attachment for nsclient.ini
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

Did you restart the NSClient++ service after adding the PSCheckCertificate command?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post by grayloglearn »

Yes I have restarted multiple times..
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

I guess next we need to look in the nsclient.log to see what errors are in there
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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++
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked