CheckWMIValue

CheckWMIValue is part of the wiki:CheckWMI module.

It is still alpha need to do more testing but I would like to get some initial feedback on the syntax and such. Also feel free to try it out and report bugs to me (might wanna keep track of memory and such as I have not done so myself yet) To debug and help you setup your queries there is also a command line interface to run queries and see the result.

nsclient++ CheckWMI <query>

The syntax for this is Similar to other check commands so it should be pretty straight forward to set it up. The plugin will run a WMI query and check the returned columns against bounds provided by the checker (nagios) and report the result.

OptionValuesDescription
MaxWarnNumeric valueThe maximum allowed value for the column(s).
MaxCritNumeric valueThe maximum allowed value for the column(s).
MinWarnNumeric valueThe minimum allowed value for the column(s).
MinCritNumeric valueThe minimum allowed value for the column(s).
ShowAllEmpty, longIf present will display information even if an item is not reporting a state. If set to long will display more information.
QueryWMI QueryThe WMI query to ask (not stackable, only one query at a time)
CheckA column nameA column name to check (if * all columns will be checked) (this is stackable, so you can compare any number of columns)
truncatenumeric valueThe maximum length of the query-result.
AliasCol?Column nameA column to be included (prefixed) in the alias for matching columns.

Examples

Check the CPU load on all CPUs and warn if above 50 and critical if above 80

Sample Command:

CheckWMIValue "Query=Select * from win32_Processor" MaxWarn=50 MaxCrit=80 Check:CPU=LoadPercentage ShowAll=long
OK: OK: Everything seems fine.
Nagios Configuration:
define command {
  command_name <<CheckWMIValue>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckWMIValue -a "Query=Select * from win32_Processor" MaxWarn=50 MaxCrit=80 Check:CPU=LoadPercentage ShowAll=long
}
<<CheckWMIValue>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckWMIValue -a "Query=Select * from win32_Processor" MaxWarn=50 MaxCrit=80 Check:CPU=LoadPercentage ShowAll=long

CHeck Threads in a process

Check threads in processes and make sure a process does not have more then 50 threads (critical at 100)

Sample Command:

CheckWMIValue "Query=select Caption, ThreadCount from Win32_Process" MaxWarn=50 MaxCrit=100 Check:threads=ThreadCount AliasCol=Caption
WARNING: System threads: 98 > warning
Nagios Configuration:
define command {
  command_name <<CheckWMIValue>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckWMIValue -a "Query=select Caption, ThreadCount from Win32_Process" MaxWarn=50 MaxCrit=100 Check:threads=ThreadCount AliasCol=Caption
}
<<CheckWMIValue>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckWMIValue -a "Query=select Caption, ThreadCount from Win32_Process" MaxWarn=50 MaxCrit=100 Check:threads=ThreadCount AliasCol=Caption

Ping status

Little example on W32_PingStatus, I use this to check my VPN tunnels.

Sample Command:

CheckWMIValue 'Query=SELECT StatusCode FROM Win32_PingStatus WHERE Address="$ARG1$"' MaxCrit=1 Check:Status:=StatusCode

Nagios Configuration:
define command {
  command_name <<CheckWMIValue>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckWMIValue -a 'Query=SELECT StatusCode FROM Win32_PingStatus WHERE Address="$ARG1$"' MaxCrit=1 Check:Status:=StatusCode
}
<<CheckWMIValue>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckWMIValue -a 'Query=SELECT StatusCode FROM Win32_PingStatus WHERE Address="$ARG1$"' MaxCrit=1 Check:Status:=StatusCode

Status-Code = 0 means good. Everything above 0 is BAD

For more information on Win32_PingStatus See:  http://msdn.microsoft.com/en-us/library/aa394350(VS.85).aspx

Using from command line

To try a query use the following syntax:

nsclient++ CheckWMI Select * from win32_Processor