Page 1 of 1

Send alert if Windows service IS running?

Posted: Fri May 18, 2012 12:40 pm
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!

Re: Send alert if Windows service IS running?

Posted: Fri May 18, 2012 1:18 pm
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.

Re: Send alert if Windows service IS running?

Posted: Fri May 18, 2012 2:30 pm
by torlok2002
Great! Exactly what I wanted. :D
Thanks for the assistance!

Re: Send alert if Windows service IS running?

Posted: Fri May 18, 2012 4:17 pm
by agriffin
Glad I could help!