Page 9 of 10

Re: Using NRPE for windows server

Posted: Tue Feb 27, 2018 3:40 pm
by skypete
Thank you that worked.. So now the we are still stuck with the services not restarting :D :D

Re: Using NRPE for windows server

Posted: Tue Feb 27, 2018 5:29 pm
by npolovenko
@skypete, Please let me know the output of the following command:

Code: Select all

ls -l /usr/local/nagios/libexec/restart_service.sh
In Nagios Web interface please click on the service check to open up a Service State Information page. In the left column click on "Submit passive check result for this service", choose Critical, put anything in the Check Output, and click on Submit.

After that please download the nagios.log file from the server and send it to us:

Code: Select all

/usr/local/nagios/var/nagios.log
Also, If you could attach the eventhandler one more time /usr/local/nagios/libexec/restart_service.sh just so I could double check that you deleted those two echo statements, that would be great.

Re: Using NRPE for windows server

Posted: Wed Feb 28, 2018 10:16 am
by skypete
Here you go hope this helps.

Re: Using NRPE for windows server

Posted: Wed Feb 28, 2018 2:49 pm
by tgriep
On the Windows servers, create a batch file called

Code: Select all

restart_service.bat
In this folder

Code: Select all

C:\Program Files\NSClient++\scripts
In that .bat file put the following

Code: Select all

@echo off

net stop %1

net start %1

@exit 0
Save the file.


In your service file, you have the _SERVICE macro defined like this

Code: Select all

_SERVICE                 "spoolsv.exe"
The windows net command doesn't stop and start the service by it's exe name. It does it by the service name,

So login to the Windows system and open up the service application and then look at the Service name for the print spooler.
On my Windows 7 system, it is called Spooler so mu service macro looks like this

Code: Select all

_SERVICE spooler
Edit your service check and update your macro's name.

To test the name, run the following commands to see if they will restart the spooler service on your 2 servers.

Code: Select all

/usr/local/nagios/libexec/servicerestart.sh CRITICAL 192.168.1.17 spooler
/usr/local/nagios/libexec/servicerestart.sh CRITICAL 192.168.1.18 spooler
If they fail, post the full output of the commands.

Re: Using NRPE for windows server

Posted: Thu Mar 01, 2018 10:08 am
by skypete
Hello I have corrected the macro spooler.exe to spooler.

When I ran the command /usr/local/nagios/libexec/restart_service.sh CRITICAL 192.168.1.17 spooler

I get Print spooler service is starting,

The Print spooler service was started successfully.

Now is there a way when the service stops it will automatically start on its own without me running /usr/local/nagios/libexec/restart_service.sh CRITICAL 192.168.1.17 spooler ?

Re: Using NRPE for windows server

Posted: Thu Mar 01, 2018 10:16 am
by tgriep
Good to hear that the tests worked. Now you know the scripts to stop and start the service works for you.

From the recent changes that I suggested, the check and the automatic starting of the service should work for you now.
Test it and see if it functions.

Re: Using NRPE for windows server

Posted: Thu Mar 01, 2018 11:06 am
by skypete
It does not automatically restart the service when it is stopped.

Re: Using NRPE for windows server

Posted: Thu Mar 01, 2018 4:30 pm
by tgriep
Did you see the Nagios server detect that the service was not running and did you see that the Event Handler run trying to restart the service in the nagios.log file?

Re: Using NRPE for windows server

Posted: Fri Mar 02, 2018 11:14 am
by skypete
Seems like its trying restart. here is the logs

Re: Using NRPE for windows server

Posted: Fri Mar 02, 2018 11:45 am
by scottwilkerson
I believe you are correct I see this

Code: Select all

[1520003818] SERVICE EVENT HANDLER: TESTSERVER1;Print Spooler;CRITICAL;HARD;1;restart-service
Please show your command config for restart-service

This is the last piece of the puzzle to get correct