check_multi

Runs multiple checks and aggregates their status, output and performance data.

By default CheckMulti is enabled, but you can disable it in the [/modules] section of the snclient_local.ini. You can also set max checks in the [/settings/check/multi] section of the snclient_local.ini, which limits the number of checks that can be configured.

When using the inline mode, you can only use available commands (run check_index to get a full list).

You can also define custom check sections in the config file, for example:

[/settings/check/multi/mycheck]
var[PROCESS] = 123
command[alias1] = check_process process=$PROCESS$
command[alias2] = check_process process=345

This can be executed with check_multi “config=mycheck”.

Use check_multi “config=mycheck” “var[PROCESS]=456” to override a variable’s default value. Variable names are case-sensitive. Every occurrence of a declared variable is replaced; undeclared placeholders stay unchanged. Shell metacharacters and control characters are forbidden in values. Quote placeholders to preserve spaces.

Variables without defaults must be declared as required (comma-separated):

[/settings/check/multi/required]
required vars = MESSAGE
command[message] = check_dummy 0 '$MESSAGE$'

Run this with check_multi “config=required” “var[MESSAGE]=Service is healthy”. A required variable must have a default or be explicitly supplied; an empty value counts as supplied.

It’s also possible to use custom scripts in the config section, for example:

[/settings/check/multi/myscript]
command[alias1] = /path/to/plugin1
command[alias2] = /path/to/plugin2
command[alias3] = /path/to/plugin3

This can be executed with check_multi “config=myscript”.

Implementation

WindowsLinuxFreeBSDmacOS
✅✅✅✅

Argument Defaults

ArgumentDefault Value
warningwarning_count > 0
criticalcritical_count > 0
unknownunknown_count > 0
empty-state3 (UNKNOWN)
empty-syntax%(status) - no checks executed
top-syntax%(status) - %(count) plugins checked: %(ok_count) ok, %(warning_count) warning, %(critical_count) critical, %(unknown_count) unknown - %(problem_list)
ok-syntax{{ if problem_count gt 0 }}%(status) - %(count) plugins checked: %(ok_count) ok, %(warning_count) warning, %(critical_count) critical, %(unknown_count) unknown - %(problem_list){{ ELSE }}%(status) - %(count) plugins checked, %(ok_count) ok{{ END }}
detail-syntax%(name): %(shortoutput)
long-detail-syntax[%(name)] %(output)

Check Specific Arguments

ArgumentDescription
commandCheck command to execute with mandatory unique tag, e.g. command[tag]=…
configConfig section name under [/settings/check/multi/< section >] to execute
varConfig variable override, e.g. var[KEY]=VALUE, replacing $KEY$ in config commands

Attributes

Filter Keywords

these can be used in filters and thresholds (along with the default attributes):

AttributeDescription
countTotal number of checks executed
ok_countNumber of checks in OK state
warning_countNumber of checks in WARNING state
critical_countNumber of checks in CRITICAL state
unknown_countNumber of checks in UNKNOWN state
problem_countNumber of checks in non-OK state
nameName/Tag of the check
tagAlias for name
commandCommand executed
stateExit code of the check (0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN)
statusStatus text of the check (OK, WARNING, CRITICAL, UNKNOWN)
outputCheck output
shortoutputFirst line of the check output

Examples

Default Check

check_multi "command[check_process]=check_process 'process=firefox'" "command[check_memory]=check_memory 'type=physical' 'crit=used_pct gt 80%'"
OK - 2 plugins checked, 2 ok |'check_process::count'=1;;;0 ... 'check_memory::physical %'=78.7%;;;0;100
[check_process] OK - all 1 processes are ok.
[check_memory] OK - physical = 12.59 GiB/16.00 GiB (78.7%)

You can define 'warning' and 'critical' conditions based on the number of checks in a certain state (see attributes above):

check_multi "command[check_dummy1]=check_dummy 0 'OK - check works'" "command[check_dummy2]=check_dummy 1 'WARNING - problem found'" "critical=problem_count gt 0"
CRITICAL - 2 plugins checked: 1 ok, 1 warning, 0 critical, 0 unknown - warning(check_dummy2: WARNING - problem found)
[check_dummy1] OK - check works
[check_dummy2] WARNING - problem found

You can also override the 'top-syntax' and use IF ELSE statements to get a certain output based on the results:

check_multi "command[check_dummy1]=check_dummy 0 'OK'" "command[check_dummy2]=check_dummy 2 'CRITICAL'" \
			"top-syntax={{ if ok_count gt 0 }}OK - %(ok_count)/%(count) checks are OK {{ ELSE }}CRITICAL - all checks failed{{ END }}"
OK - 1/2 checks are OK
[check_dummy1] OK
[check_dummy2] CRITICAL

Example using check_snclient and Naemon

Naemon Config

define command{
    command_name         check_snclient
    command_line         $USER1$/check_snclient -k -p 'your-password' -u 'https://$HOSTADDRESS$:8443' $ARG1$ $ARG2$
}

define service {
    host_name            testhost
    service_description  check_multi
    use                  generic-service
    check_command        check_snclient!check_multi!"command[check_cpu]=check_cpu" "command[check_memory]=check_memory"
}