Page 7 of 10

Re: Using NRPE for windows server

PostPosted: Thu Feb 15, 2018 4:29 pm
by skypete
npolovenko wrote:
It will only work when i ran the /usr/local/nagios/libexec/check_nrpe -H (IP Adress of server) -c restart_service -a spooler than it will go back to its current state.

You're saying that running this command manually changes what you see in the UI? That is impossible.
when I run chown apache:nagios /usr/local/nagios/libexec/restart_service.sh i get this error chown: invlaid user: apache:nagios

You can try chown apache.nagios /usr/local/nagios/libexec/restart_service.sh



No sorry I meant when i run that command it automatically restarts the service.
And when i chown apache.nagios /usr/local/nagios/libexec/restart_service.sh same error

Re: Using NRPE for windows server

PostPosted: Thu Feb 15, 2018 4:40 pm
by npolovenko
@skypete, Well it says it's running.

root@ubuntu:/usr/local/nagios/libexec# ./check_nrpe -H IP ADDRESS -c check_process -a process=spoolsv.exe show-all
OK: spoolsv.exe=started|'spoolsv.exe state'=1;0;0 'count'=1;0;0


But that's only one of two commands that I asked you to run. Did you also stop the service on windows and then checked with nrpe one more time? Please show the nrpe check when the service is down.

Please make the service go into the critical state again and then upload the testing.txt file so that we can see what's going on.

Please upload the file.

Re: Using NRPE for windows server

PostPosted: Thu Feb 15, 2018 4:46 pm
by skypete
The Service does not go into any critical state like i mentioned before it only stays at green even though i would stop the service on the window server.

here are the results of the command.

root@ubuntu:/usr/local/nagios/libexec# ./check_nrpe -H IP ADDRESS -c check_process -a process=spoolsv.exe show-all
CRITICAL: critical(spoolsv.exe=stopped)|'spoolsv.exe state'=0;0;0 'count'=1;0;0

Re: Using NRPE for windows server

PostPosted: Thu Feb 15, 2018 6:02 pm
by npolovenko
@skypete, I modified the event handler script earlier. This is the most recent version that I was referring to. I need the testing.txt output from this event handler.

Code: Select all
#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$3"
echo "/usr/local/nagios/libexec/check_nrpe -H \"$2\" -p 5666 -c restart_service -a \"$3\"" > testing.txt

;;
esac


Also, If the service checks never went red how did the event handler run?

The Service does not go into any critical state like i mentioned before it only stays at green even though i would stop the service on the window server.

Did you wait 5 minutes after you turned off the windows service before checking in the GUI? Click on the print spooler service in nagios core web interface, then click on Re-schedule the next check of this service.

Re: Using NRPE for windows server

PostPosted: Fri Feb 16, 2018 10:43 am
by skypete
Did you wait 5 minutes for it to turn red?
I have multiple times waited and restarted and no luck.

Also the testing file is not showing up,the only way for it to show up in the libexec folder is to run this command which created the file.

echo "Event handler works!" > testing.txt

Could you explain step by step to get install maybe i missed something sorry. note I do have this as a bat script also will the testing.txt file when it is created would it be in the libexec folder?

@echo off
net stop %1
net start %1
@exit 0

And it is save in this directory
C:\Program Files\NSClient++\scripts\

Re: Using NRPE for windows server

PostPosted: Fri Feb 16, 2018 2:25 pm
by npolovenko
@skypete, Since you can restart a windows service remotely with that NRPE command I wouldn't worry about that.
And when you run this:
root@ubuntu:/usr/local/nagios/libexec# ./check_nrpe -H IP ADDRESS -c check_process -a process=spoolsv.exe show-all
CRITICAL: critical(spoolsv.exe=stopped)|'spoolsv.exe state'=0;0;0 'count'=1;0;0

You get the correct output. But in the Core Web interface, it's still green, which makes me believe that your host definition is incorrect. When we created a service:
Code: Select all
define service {
host_name HostName
service_description Print Spooler

What did you put instead of HostName?
Did you define the host for windows service?
Code: Select all
define host {
    host_name              HostName
    address                 192.168.1.10
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    contacts                nagiosadmin
    notification_interval   60
    notification_period     24x7
    notifications_enabled   1
}

And then the hostname in define_service has to match the hostname in define_host. IP address in host definition has to be the real windows server IP. Can you double check on that, please?

In both service definition and host definition please temporarely change:
Code: Select all
max_check_attempts to 1
check_interval to 3
retry_interval to 1

Re: Using NRPE for windows server

PostPosted: Fri Feb 16, 2018 2:50 pm
by skypete
Hi thanks I do have two windows servers i am testing on just to see the if both have any issues running the service defentions. I did put the the correct hostname of the servers in the define host line and the ip address so i double checked it and they are both correct.


I did temporarely change

Code: Select all
max_check_attempts to 1
check_interval to 3
retry_interval to 1

still same issue sorry :) i did upload my clientini file maybe there is some setting that is not enabled?

Re: Using NRPE for windows server

PostPosted: Fri Feb 16, 2018 5:59 pm
by npolovenko
@skypete, Can you download and zip the whole /usr/local/nagios/etc/ folder on the Nagios Server using Filezilla or WinSCP and upload it here?

Re: Using NRPE for windows server

PostPosted: Tue Feb 20, 2018 9:25 am
by skypete
Here you go.

Re: Using NRPE for windows server

PostPosted: Wed Feb 21, 2018 1:37 pm
by npolovenko
@skypete. The config looks fine. Can you stop these 2 windows services again, then wait 20 minutes, refresh Nagios core web interface and check if the status of the service checks changed to red. If not please upload the /usr/local/nagios/var/nagios.log file, and also nsclient.log file from the windows server. Also nsclient.ini file, please.