Alert if a Service IS 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

Alert if a Service IS running

Post by neworderfac33 »

Good afternoon,
I created a command in commands.cfg

Code: Select all

define command {
        command_name    negatepr
        command_line    $USER1$/negate $USER1$/$ARG1$
}
to allow Nagios to generate an alert if a particular application WAS running, rather than if it wasn't:

Code: Select all

#define service{
#        use                      generic-service
#        hostgroup_name           jenkins-test-masters,jenkins-slaves
#       service_description      Alert if running - Notepad
#       check_command            negatepr!check_nt -H $HOSTADDRESS$ -p 12489 -v PROCSTATE -d SHOWALL -l notepad.exe
#        }
and this runs fine. Now I want to extend this functionality to alert when a SERVICE is running, but when I use this:

Code: Select all

define service{
        use                     generic-service
        hostgroup_name          jenkins-test-masters
        service_description     Service active - Tomcat7
        check_command           negatepr!check_nt -H $HOSTADDRESS$ -p 12489 - v SERVICESTATE -d SHOWALL -l Tomcat7
        }
the browser returns "check_nt: Could not parse arguments "

Do I need to create a different negate command that will work with services, rather than applications?

[EDIT] - another typo - I had a space between the "-" and the "v" above, although it's not easy to spot. Removed it, restarted and all is fine!

Pete
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Alert if a Service IS running

Post by hsmith »

peterooney wrote:Good afternoon,
I created a command in commands.cfg

Code: Select all

define command {
        command_name    negatepr
        command_line    $USER1$/negate $USER1$/$ARG1$
}
to allow Nagios to generate an alert if a particular application WAS running, rather than if it wasn't:

Code: Select all

#define service{
#        use                      generic-service
#        hostgroup_name           jenkins-test-masters,jenkins-slaves
#       service_description      Alert if running - Notepad
#       check_command            negatepr!check_nt -H $HOSTADDRESS$ -p 12489 -v PROCSTATE -d SHOWALL -l notepad.exe
#        }
and this runs fine. Now I want to extend this functionality to alert when a SERVICE is running, but when I use this:

Code: Select all

define service{
        use                     generic-service
        hostgroup_name          jenkins-test-masters
        service_description     Service active - Tomcat7
        check_command           negatepr!check_nt -H $HOSTADDRESS$ -p 12489 - v SERVICESTATE -d SHOWALL -l Tomcat7
        }
the browser returns "check_nt: Could not parse arguments "

Do I need to create a different negate command that will work with services, rather than applications?

[EDIT] - another typo - I had a space between the "-" and the "v" above, although it's not easy to spot. Removed it, restarted and all is fine!

Pete
Ooops. I assume you want me to close this one? :lol:
Former Nagios Employee.
me.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Alert if a Service IS running

Post by neworderfac33 »

Incidentally, it DOES work if you set up a dedicated command on commands.cfg

Code: Select all

define service{
        use                     generic-service
        hostgroup_name          jenkins-test-masters
        service_description     Service active - Tomcat7
        check_command           TomcatServiceRunning
        }
used in conjunction with:

Code: Select all

define command {
        command_name    TomcatServiceRunning
        command_line    $USER1$/negate $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v SERVICESTATE -d SHOWALL -l Tomcat7
}
just in case anyone wants to know how to set up a command relating to a specific service.

Cheers

Pete
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Alert if a Service IS running

Post by neworderfac33 »

And yes, please - this can be closed - titter ye not! :oops:
Locked