-
Notifications
You must be signed in to change notification settings - Fork 19
Add check_multi #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
lgmu
wants to merge
26
commits into
ConSol-Monitoring:main
Choose a base branch
from
lgmu:check-multi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,288
−100
Draft
Add check_multi #451
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
d8c56d5
add check_multi
lgmu 15e36f1
fix test, problem_count should be 1 here
lgmu c8b007d
fix windows tests
lgmu db3ec6c
Merge branch 'main' into check-multi
lgmu 4fc5bc2
fix DOC_COMMANDS
lgmu 461bc15
update docs
lgmu 6542be3
improve docs
lgmu f8e8192
max checks documentation improvement
lgmu c99671c
add _skip, fix potential duplicated output, add example
lgmu c4fdee4
fix citest
lgmu 2d753ad
Merge branch 'main' into check-multi
lgmu f46c13a
add unknown condition
lgmu 48c30df
fix golangci lint
lgmu bd6e536
Merge branch 'main' into check-multi
lgmu c1c6944
adjust syntax, add new attributes, changed default output
lgmu e13e652
remove duplication check here because config parser already deduplicates
lgmu 9356b3d
Merge branch 'main' into check-multi
lgmu 4bba3be
improve max checks handling
lgmu 5308a83
Merge branch 'main' into check-multi
lgmu 72a5664
fix tests
lgmu 83ca431
fix conditions
lgmu 4619308
Merge branch 'main' into check-multi
lgmu 41c17b1
fix typo in Makefile
lgmu 492b904
remove leftover
lgmu 141e604
fix cfg duplicate, tags, literal output
lgmu 5631ddf
Merge branch 'main' into check-multi
lgmu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| --- | ||
| 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] | ||
| command[alias1] = check_process process=123 | ||
| command[alias2] = 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] | ||
| command[alias1] = /path/to/plugin1 | ||
| command[alias2] = /path/to/plugin2 | ||
| command[alias3] = /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 "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 below): | ||
|
|
||
| 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 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 | 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 | {{ 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): %(output) | | ||
|
|
||
| ## Check Specific Arguments | ||
|
|
||
| | Argument | Description | | ||
| | -------- | ------------------------------------------------------------------------- | | ||
| | command | Check command to execute with mandatory unique tag, e.g. command[tag]=... | | ||
| | 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 | | ||
| | tag | Alias for name | | ||
| | 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 | Check output | | ||
| | shortoutput | First line of the check output | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.