Using NRPE for windows server

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Re: Using NRPE for windows server

Postby skypete » Tue Feb 27, 2018 3:40 pm

Thank you that worked.. So now the we are still stuck with the services not restarting :D :D
skypete
 
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Postby npolovenko » Tue Feb 27, 2018 5:29 pm

@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.
npolovenko
Support Tech
 
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Using NRPE for windows server

Postby skypete » Wed Feb 28, 2018 10:16 am

Here you go hope this helps.
Attachments
nagios.log
(18.5 KiB) Downloaded 256 times
Output.txt
(390 Bytes) Downloaded 282 times
restart_service.sh
(159 Bytes) Downloaded 276 times
skypete
 
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Postby tgriep » Wed Feb 28, 2018 2:49 pm

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8212
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE for windows server

Postby skypete » Thu Mar 01, 2018 10:08 am

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 ?
skypete
 
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Postby tgriep » Thu Mar 01, 2018 10:16 am

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8212
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE for windows server

Postby skypete » Thu Mar 01, 2018 11:06 am

It does not automatically restart the service when it is stopped.
skypete
 
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Postby tgriep » Thu Mar 01, 2018 4:30 pm

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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8212
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE for windows server

Postby skypete » Fri Mar 02, 2018 11:14 am

Seems like its trying restart. here is the logs
Attachments
nagios.log
(19.61 KiB) Downloaded 268 times
skypete
 
Posts: 98
Joined: Sat Dec 02, 2017 11:44 pm

Re: Using NRPE for windows server

Postby scottwilkerson » Fri Mar 02, 2018 11:45 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

PreviousNext

Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 2 guests