Using NRPE for windows server

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
skypete
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Post by skypete »

Thank you that worked.. So now the we are still stuck with the services not restarting :D :D
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Using NRPE for windows server

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
skypete
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Post by skypete »

Here you go hope this helps.
Attachments
nagios.log
(18.5 KiB) Downloaded 413 times
Output.txt
(390 Bytes) Downloaded 439 times
restart_service.sh
(159 Bytes) Downloaded 457 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE for windows server

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
skypete
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Post 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 ?
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE for windows server

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
skypete
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Post by skypete »

It does not automatically restart the service when it is stopped.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE for windows server

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
skypete
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Post by skypete »

Seems like its trying restart. here is the logs
Attachments
nagios.log
(19.61 KiB) Downloaded 415 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Using NRPE for windows server

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