Send alert if Windows 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
torlok2002
Posts: 2
Joined: Fri May 18, 2012 12:33 pm

Send alert if Windows service IS running?

Post by torlok2002 »

Hi all, first post to this board. I've been playing with this idea for a couple of days and have yet to make a working solution. I have a Windows server that has a service that allows remote access. I want to alert the team if it IS running so there is a reminder to turn this service back off, in effect limiting remote access to only the times it is needed.

I've tried playing around with the check_nt command as follows:

Code: Select all

check_nt -H $SERVERNAME$ -p 12489 -v SERVICESTATE -l $SERVICENAME$

Here is the service in the host which checks as normal (alert if not running):

Code: Select all

define service{
        hosts                           $SERVERNAME$
        service_description             Apache Tomcat
        check_command                   check_nt!$SERVICENAME$
        use                             generic-service
        notification_interval           0 ; set > 0 if you want to be renotified
        contact_groups                  IT
}
but am just returned the service name or an OK state. Any ideas on how to basically do the reverse of what Nagios is intended to do?

Thanks in advance!
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Send alert if Windows service IS running?

Post by agriffin »

There is plugin called negate which does what you want. In your command definition, just add $USER1$/negate in front of your real check command.
torlok2002
Posts: 2
Joined: Fri May 18, 2012 12:33 pm

Re: Send alert if Windows service IS running?

Post by torlok2002 »

Great! Exactly what I wanted. :D
Thanks for the assistance!
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Send alert if Windows service IS running?

Post by agriffin »

Glad I could help!
Locked