Check for multiple instances of a running program

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Check for multiple instances of a running program

Post by JohnFLi »

I need a check that will alert if 15 or more instantnaces of cmd.exe is running on a host. We have a system that runs several bat files on another system (thus using cmd.exe) The calling system is able to check to insure it's running, but if it 'hangs' the calling system will start another instance. If the first instanance is hung, then the second, third, forth, etc still wont run becasue the first is stuck.

So anyway, I need a check that will let me know if more than 14 instanaces of cmd.exe is running.


Any ideas?
Everybody is somebody else’s weirdo
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Check for multiple instances of a running program

Post by dwhitfield »

Correct me if I'm wrong, but https://exchange.nagios.org//directory/ ... nt/details seems like exactly what you want.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Check for multiple instances of a running program

Post by cdienger »

Or if you're using ncpa you can do this with:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H <client.ip> -t '<token>' -M 'processes' -c 15 -q 'name=cmd.exe'
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Check for multiple instances of a running program

Post by JohnFLi »

in therory the plugin from exchange.nagios would work, except the website that has the 2 other part that is needed, doesn't exist anymore

This plugin relied on two specific pieces to work properly
if at all:
NC_Net (http://http://www.shatterit.com/nc_net/) on the client
and
check_nt (http://www.shatterit.com/nc_net/files/check_nt.c)
Everybody is somebody else’s weirdo
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Check for multiple instances of a running program

Post by dwhitfield »

When archive.org is back up I'll take a look (https://archive.org/search.php?query=ht ... Fnc_net%2F), but is NCPA an option for you?
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Check for multiple instances of a running program

Post by JohnFLi »

you can go ahead and close this item.

I got thinking over the weekend that since I'm wanting to check this against a windows machine, why not do it in powershell.

so in powershell I came up with this simple little script:

Code: Select all

param($num, $executablename)
$ErrorActionPreference = "SilentlyContinue"


$NumofProcess = (Get-Process -Name $executablename).Count
if ($NumofProcess -gt $num) 
        {$LastExitCode = 2}
    else
        {$LastExitCode = 0}

write-host  $LastExitCode

exit $LastExitCode
Everybody is somebody else’s weirdo
Locked