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

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.
Locked
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

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

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

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

Post 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)"
Former Nagios employee
https://www.mcapra.com/
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

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

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

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

Post 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
Former Nagios employee
https://www.mcapra.com/
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

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

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

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

Post by npolovenko »

@neworderfac33, Do you have any other questions for us? Can i go ahead and close this thread as resolved?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

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

Post by neworderfac33 »

Yes, the thread can be closed, thank you.
kyang

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

Post 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!
Locked