Page 1 of 1
Difining a new service in nagios
Posted: Fri Oct 24, 2014 6:52 am
by ichayan
Hi All
I am quiet a beginner in nagios. I have found a powershell script to check the certificate expiry on windows machine. And it works directly on the machine. I found the script here
http://exchange.nagios.org/directory/Pl ... ck/details
http://networklore.com/windows-certificate-expiration/
The scripts works fine on the powershell window and I have added the following lines to nsc.ini
[/settings/external scripts/scripts]
check_win_cert=cmd /c echo scripts\nm-check-certificate-expiration.ps1; exit $LastExitCode | powershell.exe -command -
as I found in this thread.
http://exchange.nagios.org/directory/Pl ... ll/details
I don't know how to get this working from nagios.
I would appreciate detailed steps and if possible a bit of explanation so that I can learn as well.
Thanks in advance
ichayan
Re: Difining a new service in nagios
Posted: Fri Oct 24, 2014 11:13 am
by WillemDH
Hello,
You should be able to make it work if you follow this procedure:
1) Download the script. Put the script in the NSCP scripts folder
2) In the nsclient.ini configuration file, define the script like this:
check_win_cert=cmd /c echo scripts\nm-check-certificate-expiration.ps1 $ARG1$; exit LastExitCode | powershell.exe -command –
3) Make a command in Nagios like this:
check_win_cert => $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -t 60 -c check_win_cert -a $ARG1$
4) Configure your service in Nagios, make use of the above created command. Make sure you use at least one parameter in $ARG1$ (like -w 10 or so)
This webpage from NSClient documentation also describes how to use Powershell files:
http://nsclient.org/nscp/wiki/guides/na ... al_scripts
Grtz
Re: Difining a new service in nagios
Posted: Fri Oct 24, 2014 11:35 am
by ichayan
Thank you for your early reply. How do I do step 3?
Re: Difining a new service in nagios
Posted: Fri Oct 24, 2014 11:39 am
by WillemDH
In Core Config Manager, go to Commands (somewhere bottom left), create a new command there or copy a working command and edit the settings.
Re: Difining a new service in nagios
Posted: Fri Oct 24, 2014 1:47 pm
by lmiltchev
ichayan, let us know if WillemDH's suggestion helped.
Re: Difining a new service in nagios
Posted: Mon Oct 27, 2014 2:52 am
by ichayan
Thank you for the replies, didn't have access to systems over weekend. Tried it this morning but I am getting error when I test the command in the web interface.
COMMAND: /usr/local/nagios/libexec/check_nrpe -H lync.mydomain.com -p 5666 -t 60 -c check_win_cert
OUTPUT: UNKNOWN: No handler for that command
nsc.ini
========
[/settings/external scripts/scripts]
check_win_cert=cmd /c echo scripts\nm-check-certificate-expiration.ps1; exit $LastExitCode | powershell.exe -command -
enabled modules
NSClientListener.dll
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
CheckEventLog.dll
CheckHelpers.dll
NSClientListener.dll
NRPEListener.dll
CheckExternalScripts.dll
Please help thank you
Re: Difining a new service in nagios
Posted: Mon Oct 27, 2014 3:47 am
by ichayan
got it working changed the nsc.ini
[/settings/external scripts/scripts]
check_win_cert=cmd /c echo scripts\nm-check-certificate-expiration.ps1; exit $LastExitCode | powershell.exe -command -
to
[External Scripts]
check_win_cert=cmd /c echo scripts\nm-check-certificate-expiration.ps1; exit $LastExitCode | powershell.exe -command -