Check runnig process

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
nag123705
Posts: 3
Joined: Fri May 17, 2013 12:16 pm

Check runnig process

Post by nag123705 »

Hi All,

I'm running Nagios Core 3.4.4 on Ubuntu and I want to monitor the "explorer.exe" process on a windows server. Easy enough but, I want the status to be OK when the process is NOT running. I want to monitor and get an alert every time a user logs on and off the server. I created a new service template and assign it to the service definition. I tried changing the "initial state" but I can't get it to work.

Any help would be greatly appreciated.

TIA
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Check runnig process

Post by sreinhardt »

You should look into using the negate plugin with your existing check. I am hoping this is a "core" windows server otherwise the request to not have explorer seems a bit odd.

http://exchange.nagios.org/directory/Do ... in/details
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Check runnig process

Post by gshergill »

Hi nag123705,

I use negate for the exact same thing you need. Below are the commands I have if they help.

commands.cfg:

Code: Select all

define command {
       command_name     negate
       command_line     /usr/local/nagios/libexec/negate -o CRITICAL -w WARNING -c OK -u UNKNOWN $ARG1$
        }
services.cfg:

Code: Select all

define service{
        use                     generic-service
        host_name               hostname
        service_description     Explorer
        check_command           negate!/usr/local/nagios/libexec/check_nt -H $HOSTADDRESS$ -s password -p 12489 -v PROCSTATE -d SHOWALL -l explorer.exe
        notification_interval   0
        normal_check_interval   1
        event_handler           custom-explorer-notify
        }
Good luck!

Kind Regards,

Gary Shergill
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Check runnig process

Post by sreinhardt »

Thanks for the input Gary!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
nag123705
Posts: 3
Joined: Fri May 17, 2013 12:16 pm

Re: Check runnig process

Post by nag123705 »

Thank you both for the replies but I can't get it to work right. I'm running the following tests:

me@host:~$ /usr/local/nagios/libexec/check_nt -H 192.168.1.1 -p 12345 -v PROCSTATE -d SHOWALL -l explorer.exe
and I get:
explorer.exe: Running

i'm running:
me@host:~$ /usr/local/nagios/libexec/negate -o CRITICAL -w WARNING -c OK -u UNKNOWN /usr/local/nagios/libexec/check_nt -H 192.168.1.1 -p 12345 -v PROCSTATE -d SHOWALL -l explorer.exe
and I get:
explorer.exe: Running

What am I doing wrong?
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Check runnig process

Post by sreinhardt »

The negate plugin only alters certain words such as critical warning, or OK. Running would not be included in that. I would suggest running your command again and following with an echo $? to show the exit code, which is the part that nagios cares about for setting check state.

Code: Select all

 /usr/local/nagios/libexec/negate -o CRITICAL -w WARNING -c OK -u UNKNOWN /usr/local/nagios/libexec/check_nt -H 192.168.1.1 -p 12345 -v PROCSTATE -d SHOWALL -l explorer.exe
echo $?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
nag123705
Posts: 3
Joined: Fri May 17, 2013 12:16 pm

Re: Check runnig process

Post by nag123705 »

Excellent!!! That did it.
Thank you both very much.
Locked