Page 1 of 1

check_nrpe to detect if process/service is/is not running

Posted: Wed Jan 03, 2018 8:38 am
by neworderfac33
Good afternoon,
I have defined the following 4 commands:

Code: Select all

#Alert if Explorer.exe PROCESS is NOT running on WINDOWS hosts using check_nrpe
define command{
        command_name check_nrpe_explorer_off
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_process process=explorer.exe "crit=state = 'stopped'" warn=none
}

#Alert if Explorer.exe PROCESS IS running on WINDOWS hosts using check_nrpe
define command{
        command_name check_nrpe_explorer_on
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_process process=explorer.exe "crit=state = 'started'" warn=none
}

#Alert if IIS SERVICE is NOT running on WINDOWS hosts using check_nrpe
define command{
        command_name check_nrpe_IIS_off
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_service service=W3SVC "crit=state = 'stopped'" warn=none
}

#Alert if IIS SERVICE IS running on WINDOWS hosts using check_nrpe
define command{
        command_name check_nrpe_IIS_on
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_service service=W3SVC "crit=state = 'started'" warn=none
}
that are respectively referenced by the following 4 services:

Code: Select all

#check_nrpe alert if Explorer Is NOT running
define service{
    use                 generic-service
    #host_name           MN2GAM12099U
    hostgroup_name      099U
    service_description NRPE_Explorer_Not_Running
    check_command       check_nrpe_explorer_off
}

#check_nrpe alert if Explorer IS running
define service{
    use                 generic-service
    #host_name           MN2GAM12099U
    hostgroup_name      099U
    service_description NRPE_Explorer_Is_Running
    check_command       check_nrpe_explorer_on
}

#check_nrpe alert if IIS/W3SVC is NOT running
define service{
    use                 generic-service
    #host_name           MN2GAM12099U
    hostgroup_name      099U
    service_description NRPE_IIS_Not_Running
    check_command       check_nrpe_IIS_off
}

#check_nrpe alert if IIS/W3SVC IS running
define service{
    use                 generic-service
    #host_name           MN2GAM12099U
    hostgroup_name      099U
    service_description NRPE_IIS_Is_Running
    check_command       check_nrpe_IIS_on
}
to check if the process Explorere.exe and the service W3SCV are or are not running.
Nagios Core 4.3.4 verifies OK, but in the GUI, the application services both return "OK: all processes are ok." and the process services both return "OK: All 146 service(s) are ok.", so it looks as though the parameters to specify explorer.exe and w3svc are being ignored.

Also, from the command line, ./check_nrpe -H 99.99.99.99 --command check_service service=nscp also returns: "OK: All 146 service(s) are ok."
Again, the part of the command specifying the service is ignored.

Can anyone suggest where I might be going wrong?
Thanks in advance and Happy New Year to all!
Pete

Re: check_nrpe to detect if process/service is/is not runnin

Posted: Wed Jan 03, 2018 10:26 am
by mcapra
Which version of NSClient++ is running on the Windows machines? This is important because many of the native NSClient++ commands are different between 0.3, 0.4, and 0.5. One parameter may work on 0.3 but be completely gone in 0.5. Though I don't think that's the problem, It's worth mentioning.

Try passing the NSClient++ arguments with the check_nrpe -a parameter. Like so:

Code: Select all

./check_nrpe -H 99.99.99.99 --command check_service -a service=nscp
./check_nrpe -H 99.99.99.99 -p 5666 -c check_service -a service=W3SVC "crit=state = 'started'" warn=none
./check_nrpe -H 10.25.14.10 -c check_service -a service=RemoteAccess "ok=state='stopped'" "warning=not state='stopped'" "critical=not state='stopped'" "perf-config=*(ignored:true)"

Re: check_nrpe to detect if process/service is/is not runnin

Posted: Wed Jan 03, 2018 10:55 am
by neworderfac33
Thanks for coming back to me!
It's 0.4.3.143
Adding -a returns the following:
./check_nrpe -H 99.99.99.99 check_service -a service=nscp
I (0.4.3.143 2015-04-29) seem to be doing fine...

./check_nrpe -H 99.99.99.99 check_service -a service=W3svc
I (0.4.3.143 2015-04-29) seem to be doing fine...

so again ignoring the specified service.

Cheers

Pete

Re: check_nrpe to detect if process/service is/is not runnin

Posted: Wed Jan 03, 2018 10:57 am
by mcapra
Be sure to include the -c flag when passing a command to NSClient++ via check_nrpe. Like so:

Code: Select all

./check_nrpe -H 99.99.99.99 -c check_service -a service=nscp

Re: check_nrpe to detect if process/service is/is not runnin

Posted: Wed Jan 03, 2018 11:25 am
by neworderfac33
I just realised that I hadn't included -a in my command definitions - adding that in and restarting Nagios makes things work fine!

Thanks very much for the hint about the differences between different versions of NSClient++ - that's what got me sorted!

Pete

Re: check_nrpe to detect if process/service is/is not runnin

Posted: Wed Jan 03, 2018 12:50 pm
by npolovenko
@neworderfac33, Do you have any other questions for us? Can i go ahead and close this thread as resolved?

Re: check_nrpe to detect if process/service is/is not runnin

Posted: Thu Jan 04, 2018 4:05 am
by neworderfac33
Yes, the thread can be closed, thank you.

Re: check_nrpe to detect if process/service is/is not runnin

Posted: Thu Jan 04, 2018 10:30 am
by kyang
Sounds good! I'll be closing this thread!

If you have any more questions, feel free to create another thread.

Thanks for using the Nagios Support Forum!