Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ DOC_COMMANDS=\
check_mailq \
check_memory \
check_mount \
check_multi \
check_network \
check_ntp_offset \
check_omd \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Further details are covered in the [documentation](https://omd.consol.de/docs/sn
| **check_mailq** | | X | X | X |
| **check_memory** | X | X | X | X |
| **check_mount** | X | X | X | X |
| **check_multi** | X | X | X | X |
| **check_network** | X | X | X | X |
| **check_nsc_web** | X | X | X | X |
| **check_ntp_offset** | X | X | X | X |
Expand Down
110 changes: 110 additions & 0 deletions docs/checks/commands/check_multi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
title: multi
---

## 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]
check_process process=123
check_process process=345

This can be executed with 'check_multi "config=mycheck"'.

It's also possible to use custom scripts in the config section, for example:
[/settings/check/multi/myscript]
/path/to/plugin1
/path/to/plugin2
/path/to/plugin3

This can be executed with 'check_multi "config=myscript"'.


- [Examples](#examples)
- [Argument Defaults](#argument-defaults)
- [Attributes](#attributes)

## Implementation

| Windows | Linux | FreeBSD | MacOSX |
|:------------------:|:------------------:|:------------------:|:------------------:|
| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

## Examples

### Default Check

check_multi "check=check_process 'process=firefox'" "check=check_memory 'crit=used_pct gt 80%'"
OK - 2 plugins checked, 2 ok | 'check_process::count'=1;;;0 'check_process::rss'=258686976B;;;0 ...
[ 1] check_process OK - all 1 processes are ok.
[ 2] check_memory OK - physical = 12.22 GiB/16.00 GiB (76.4%), swap = 1.95 GiB/3.00 GiB (65.0%)

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

check_multi "check=check_dummy 0 'OK'" "check=check_dummy 1 'WARNING'" "critical=problem_count gt 0"
CRITICAL - 2 plugins checked: 1 ok, 1 warning, 0 critical, 0 unknown
[ 1] check_dummy OK
[ 2] check_dummy WARNING

### Example using NRPE and Naemon

Naemon Config

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -n -c $ARG1$ -a $ARG2$
}

define service {
host_name testhost
service_description check_multi
use generic-service
check_command check_nrpe!check_multi!
}

## Argument Defaults

| Argument | Default Value |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| warning | warning_count > 0 |
| critical | critical_count > 0 \|\| unknown_count > 0 |
| empty-state | 3 (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 | %(status) - %(count) plugins checked, %(ok_count) ok |
| detail-syntax | [%(status)] %(name): %(output) |

## Check Specific Arguments

| Argument | Description |
| -------- | ------------------------------------------------------------------------ |
| check | Check command to execute (can be specified multiple times) |
| config | Config section name under [/settings/check/multi/< section >] to execute |

## Attributes

### Filter Keywords

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

| Attribute | Description |
| -------------- | --------------------------------------------------------------- |
| count | Total number of checks executed |
| ok_count | Number of checks in OK state |
| warning_count | Number of checks in WARNING state |
| critical_count | Number of checks in CRITICAL state |
| unknown_count | Number of checks in UNKNOWN state |
| problem_count | Number of checks in non-OK state |
| name | Name/tag of the check |
| command | Command executed |
| state | Exit code of the check (0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN) |
| status | Status text of the check (OK, WARNING, CRITICAL, UNKNOWN) |
| output | Output of the check |
8 changes: 8 additions & 0 deletions packaging/snclient.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ CheckWMI = disabled
; CheckLogFile - Controls whether check_logfile is allowed or not.
CheckLogFile = disabled

; CheckMulti - Controls whether check_multi is allowed or not.
CheckMulti = enabled


[/settings/default]
; allowed hosts - Comma separated list of ips/networks/hostname allowed to connect.
Expand Down Expand Up @@ -357,6 +360,11 @@ allowed pattern += /var/log/snclient/snclient.log
max lines per file limit = 1000000


[/settings/check/multi]
; max checks - Maximum number of checks check_multi can execute.
max checks = 20


; External script settings - General settings for the external scripts module (CheckExternalScripts).
[/settings/external scripts]

Expand Down
2 changes: 1 addition & 1 deletion pkg/snclient/check_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestCheckFiles(t *testing.T) {

res = snc.RunCheck("check_files", []string{"path=./t/checksum.txt", "crit=md5_checksum != 3687C5D7106484CD61CDE867A2A999FA"})
assert.Equalf(t, CheckExitCritical, res.State, "CRITICAL")
assert.Contains(t, string(res.BuildPluginOutput()), "0/1 files")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discuss with @sni why it was 0 in the first place

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is passing without changes on windows for the latest main commit f9a22ac

the file MD5 is 3687C5D7106484CD61CDE867A2A999FA so raising critical is correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea but problem_count is 0, while it should be 1.
CRITICAL is still expected, nothing has changed there

assert.Contains(t, string(res.BuildPluginOutput()), "1/1 files")

res = snc.RunCheck("check_files", []string{"path=./t/checksum.txt", "crit=sha1_checksum == 4EE4BFE9AA51E56A7BD5CCF4785C35A27EE022F8"})
assert.Equalf(t, CheckExitOK, res.State, "state OK")
Expand Down
Loading