Page 1 of 1

Return Critical if no process is running

Posted: Fri Sep 11, 2015 7:14 am
by adminfun
Dear members

I have a certain process that has to be monitored.
If the process isn't running it should return Critical.
Below is the code what I have so far, but it always returns critical.

Code: Select all

./check_wmi_plus.pl -H 10.20.1.203 -u <username> -p <password> -m checkprocess -s Commandline -a PDFCreator.exe -c 0
CRITICAL - [Triggered by _ItemCount>0] - Found 2 Instance(s) of "PDFCreator.exe" running (0 excluded).  (List is on next line)|'Process Count'=2;0; 'Excluded Process Count'=0;
If the process isn't running, it returns OK. It should be the other way around. :?
What's wrong with this line of code?

Re: Return Critical if no process is running

Posted: Fri Sep 11, 2015 7:25 am
by adminfun
Dear members

Found it after some trial and error.
Seems like with ":" you can set how many processes there are allowed to run.

Code: Select all

./check_wmi_plus.pl -H 10.20.1.203 -u <username> -p <password> -m checkprocess -s Commandline -a PDFCreator.exe -c 1:2
So if the PDFCreator.exe process is running once or twice, it returns ok. But if the process is running 3 times or isn't running at all it returns Critical.

Suggestions are still welcome.

Re: Return Critical if no process is running

Posted: Fri Sep 11, 2015 9:22 am
by lmiltchev
You can just run:

Code: Select all

./check_wmi_plus.pl -H 10.20.1.203 -u <username> -p <password> -m checkprocess -a PDFCreator.exe -c 1:
The output should be "Critical" if "PDFCreator.exe" is not running. See the explanation of the "threshold and ranges" here:

https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT

Re: Return Critical if no process is running

Posted: Thu Sep 17, 2015 7:44 am
by adminfun
A bit confusing that it works different with services...

Code: Select all

./check_wmi_plus.pl -H 10.20.1.88 -u <username> -p <password> -m checkservice -a WsusService -c 0
...works perfectly when the service isn't running.

Re: Return Critical if no process is running

Posted: Thu Sep 17, 2015 3:12 pm
by ssax
Did you try it with the : on the end?

Code: Select all

./check_wmi_plus.pl -H 10.20.1.88 -u <username> -p <password> -m checkservice -a WsusService -c 0:

Re: Return Critical if no process is running

Posted: Mon Sep 21, 2015 4:33 am
by adminfun
No without the ":" for services.
And it works perfectly that way.

Re: Return Critical if no process is running

Posted: Mon Sep 21, 2015 4:11 pm
by tgriep
Those commands return different data so that may be the difference you are seeing. Below is the description for those commands.
If you don't have any more questions, shall we close this post?
checkprocess
SUBMODE Set this to Name, ExecutablePath, or Commandline to determine if ARG1 and ARG3 matches against just the
process name (Default), the full path of the executable file, or the complete command line used to run the process.
ARG1 A regular expression to match against the process name, executable path or complete command line.
The matching processes are included in the resulting list. Use . alone to include all processes. Typically the process
- Executable Path is like DRIVE:PATH/PROCESSNAME eg C:/WINDOWS/system32/svchost.exe,
- Command Line is like DRIVE:PATH/PROCESSNAME PARAMETERS eg C:/WINDOWS/system32/svchost.exe -k LocalService
Use '/' (forward slash) instead of '\\' (backslash). eg "C:/Windows" or "C:/windows/system32"
Note: Any '/' in your regular expression will get converted to '\\'.
ARG2 Set this to 'Name' (Default), Executablepath or 'Commandline' to display the process names, executablepath or the
whole command line.
ARG3 A regular expression to match against the process name, executable path or complete command line.
The matching processes are excluded from the resulting list. This exclusion list is applied after the inclusion list.

For SUBMODE and ARG2 you only need to specify the minimum required to make it unique. Any of the following will work
-s e, -s exe, -s c, -s com, -o e, -o exe, -o c, -o com
WARN/CRIT can be used as described below.
Valid Warning/Critical Fields are: _ItemCount (Default), _NumExcluded

checkservice
ARG1 A regular expression that matches against the short or long service name that can be seen in the properties of the
service in Windows. The matching services are included in the resulting list. Use . alone to include all services.
Use Auto to check that all automatically started services are OK.
ARG2 A regular expression that matches against the short or long service name that can be seen in the properties of the
service in Windows. The matching services are excluded in the resulting list.
This exclusion list is applied after the inclusion list.
WARN/CRIT can be used as described below.
Valid Warning/Critical Fields are: _NumBad (Default), _NumGood, _NumExcluded, _Total