Page 1 of 1
Check for multiple instances of a running program
Posted: Fri Dec 29, 2017 3:29 pm
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?
Re: Check for multiple instances of a running program
Posted: Fri Dec 29, 2017 3:52 pm
by dwhitfield
Correct me if I'm wrong, but
https://exchange.nagios.org//directory/ ... nt/details seems like exactly what you want.
Re: Check for multiple instances of a running program
Posted: Fri Dec 29, 2017 4:01 pm
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'
Re: Check for multiple instances of a running program
Posted: Fri Dec 29, 2017 4:16 pm
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)
Re: Check for multiple instances of a running program
Posted: Fri Dec 29, 2017 5:55 pm
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?
Re: Check for multiple instances of a running program
Posted: Tue Jan 02, 2018 2:07 pm
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