CheckCounter

Used to check performance counters. This is probably how most things can be checked as there are a lot of performance counters. To find performance counters, use the program perfmon that is shipped with windows. You can list all available performance counters using the listpdh option as shown in the examples below.

An important note is that performance counters are language and version specific.

OptionValuesDescription
MaxWarnNumberMaximum allowed number
MaxCritNumberMaximum allowed number
MinWarnNumberMinimum allowed number
MinCritNumberMinimum allowed number
ShowAllNoneA Boolean flag to show value even if no state is returned.
CounterPerformance CounterAdd a performance counter to this check
Counter:<name>Performance CounterAdd a named performance counter. The <name> will be used as an alias.
Averagestrue, falseSet this to false to make performance checking faster of counters that doesn't represent average values.
InvalidStatus?UNKNOWNThe status to return if an invalid counter was requested.

FAQ

  • Q: When using CheckCounter, does the NSClient++ client need to allow nasty chars? E.g. do you have to change the default setting: allow_nasty_chars=0 to.... allow_nasty_chars=1 ?
  • A: No, you can configure it via aliases as well using the CHeckExternalCommands module. but to configure it from "nagios" you need it.
  • Q: How do you configure NSClient++ to allow you to use all the backslashes that you'll have to feed CheckCounter?
  • A: On the target server, edit NSC.ini and add to the [NRPE] section
    allow_nasty_meta_chars=1
    
    (NOT allow_nasty_metachars and NOT allow_nasty_chars, like all the docs tell you)
  • Q: How do you define local commands?
  • A: Use the alias section from external commands
  • Q: How do you list all instances of a counter?
  • A: Use the listCounterInstances command e.g. check_nrpe -c listCounterInstances -a "MSExchange Database"

Command line

List all available performance counters, and debug them (means, open, try to read, close, etc)

nsclient++ CheckSystem listpdh
...
"NSClient++.exe" CheckSystem debugpdh
...

check_nt vs. check_nrpe

define command {
        command_name    check_counter
#       command_line    $USER1$/check_nt $HOSTADDRESS$ -p 12489 
                -v COUNTER -l $ARG1$ -d SHOWALL -w $ARG2$ -c $ARG3$
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ 
                -c CheckCounter -a $ARG1$ ShowAll MaxWarn=$ARG2$ MaxCrit=$ARG3$
}

Examples

Sample Command

Check that mutex count (on WinXP) is below 500:

Sample Command:

CheckCounter "Counter:mutex=\\Objects\\Mutexes" ShowAll MaxWarn=500 MaxCrit=1000
WARNING: WARNING: mutex: 673 > warning
Nagios Configuration:
define command {
  command_name <<CheckCounter>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckCounter -a "Counter:$ARG1$=$ARG2$" ShowAll MaxWarn=$ARG3$ MaxCrit=$ARG4$
}
<<CheckCounter>> mutex!\\Objects\\Mutexes!500!1000
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckCounter -a "Counter:mutex=\\Objects\\Mutexes" ShowAll MaxWarn=500 MaxCrit=1000

Using Instances

Using instances in counters

Sample Command:

CheckCounter "Counter:proc=\\Processor(_total)\\% Processor Time" ShowAll MaxWarn=50 MaxCrit=80
OK: ...
Nagios Configuration:
define command {
  command_name <<CheckCounter>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckCounter -a "Counter:$ARG1$=$ARG2$" ShowAll MaxWarn=$ARG3$ MaxCrit=$ARG4$
}
<<CheckCounter>> proc!\\Processor(_total)\\% Processor Time!50!80
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckCounter -a "Counter:proc=\\Processor(_total)\\% Processor Time" ShowAll MaxWarn=50 MaxCrit=80

Microsoft Exchange 5.5 IS RPC Operations / Sec

Sample Command:

CheckCounter "Counter=\MSExchangeIS\RPC Operations/sec" ShowAll MaxWarn=300 MaxCrit=400
OK: ...
Nagios Configuration:
define command {
  command_name <<CheckCounter>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckCounter -a "Counter=$ARG1$" ShowAll MaxWarn=$ARG2$ MaxCrit=$ARG3$
}
<<CheckCounter>> \MSExchangeIS\RPC Operations/sec!300!400
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckCounter -a "Counter=\MSExchangeIS\RPC Operations/sec" ShowAll MaxWarn=300 MaxCrit=400

Windows 2000/2003 Physical Disk Time

Sample Command:

CheckCounter "Counter=\PhysicalDisk(_Total)\% Disk Time" ShowAll MaxWarn=60 MaxCrit=90
OK: ...
Nagios Configuration:
define command {
  command_name <<CheckCounter>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckCounter -a "Counter=$ARG1$" ShowAll MaxWarn=$ARG2$ MaxCrit=$ARG3$
}
<<CheckCounter>> \PhysicalDisk(_Total)\% Disk Time!60!90
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckCounter -a "Counter=\PhysicalDisk(_Total)\% Disk Time" ShowAll MaxWarn=60 MaxCrit=90