CheckMKClient¶
check_mk client can be used both from command line and from queries to check remote systems via check_mk
Enable module¶
To enable this module and allow using the commands you need to add CheckMKClient = enabled to the [/modules] section in nsclient.ini:
[/modules]
CheckMKClient = enabled
Queries¶
A quick reference for all available queries (check commands) in the CheckMKClient module.
List of commands:
A list of all available queries (check commands)
| Command | Description |
|---|---|
| check_mk_query | Request remote information via check_mk. |
check_mk_query¶
Request remote information via check_mk.
About check_mk_query¶
check_mk_query connects to a remote check_mk agent, retrieves its output
and hands it to a Lua script that turns it into a check result. It is the active
half of the check_mk support: the agent on the far end is a check_mk agent, not
NSClient++.
The Lua script does the work¶
Unlike the other client modules, check_mk_query does not itself interpret what
it fetched. The check_mk agent returns a sectioned plain-text dump — <<<mem>>>,
<<<df>>>, <<<ps>>> and so on — and a Lua script registered under the
module’s scripts section is called back with the parsed packet to decide what
the status and message should be. default_check_mk.lua is loaded when no
script is configured.
That means the useful configuration for this command is mostly not on the
command line: what the check reports is whatever your script returns. Point
scripts at your own file when you want anything other than the default
behaviour.
Connection¶
The usual client options apply — host= (with port=, defaulting to the
module’s configured value), or target= to use a target defined in the module’s
settings, plus timeout=, retries= and the TLS options (certificate=,
ca=, verify=, allowed-ciphers=).
Note that a stock check_mk agent listens on TCP 6556 in plain text, with
access control done by source-IP allowlist rather than by authentication, so set
port=6556 explicitly unless you have configured otherwise, and treat the
transport as unauthenticated unless you have put TLS in front of it.
See also the CheckMKServer module for the passive direction — serving check_mk agent output from this host to a check_mk server.
Jump to section:
Sample Commands¶
Query a remote check_mk agent:
A stock check_mk agent listens on TCP 6556, so the port normally has to be given explicitly — the module’s own default is 5667.
check_mk_query host=192.168.56.20 port=6556
OK: check_mk agent responded
Use a configured target:
[/settings/check_mk/client/targets/linux01]
address = 192.168.56.20:6556
timeout = 30
check_mk_query target=linux01
OK: check_mk agent responded
What the check actually reports is decided by the Lua script:
The agent returns a sectioned plain-text dump (<<<mem>>>, <<<df>>>,
<<<ps>>>, …), and a Lua script registered on the module is called back with
the parsed packet to produce the status and message. With no script configured,
default_check_mk.lua is loaded.
[/settings/check_mk/client/scripts]
mine = check_mk_custom.lua
check_mk_query target=linux01
CRITICAL: /var 94% used
Change the script, not the command line, when you want different behaviour.
Nothing listening:
check_mk_query host=127.0.0.1 port=15670
UNKNOWN: Error: Failed to connect to: 127.0.0.1:15670 :Connection refused
A note on the transport:
A stock check_mk agent speaks plain text on 6556 with access control by
source-IP allowlist rather than authentication. Treat it as unauthenticated
unless you have put TLS in front of it, and configure ca / verify /
certificate accordingly where you have.
See also the CheckMKServer module for the passive direction — serving check_mk agent output from this host.
Data sources and privileges¶
| Source | Provides | Privilege | Requires | Notes |
|---|---|---|---|---|
| Remote Checkmk agent: TCP connect, read the sectioned agent output until the agent closes (optionally over TLS) | the parsed agent sections, handed to the Lua callback registered for check_mk (default_check_mk.lua when no script is configured) |
none | A Checkmk agent reachable on host/port (the connection falls back to 6556 when the address has no port; configured targets default to 5667)Lua (the module is only built when Lua is found) With ssl: OpenSSL support and, by default, a CA (ca) that verifies the agent’s certificate (verify mode defaults to peer) |
note 1 |
- The result is not taken from the Lua callback: after a successful exchange the response is OK
Data presumably sent successfully. Without it: A connection or TLS failure is UNKNOWNSocket error: ....
Privilege is what the account the NSClient++ agent runs as needs, not the caller of the check: elevated means Administrator or LocalSystem on Windows and root on Linux and macOS. Not determined means nobody has worked it out yet - not that none is needed. See also all checks by privilege.
Command-line Arguments¶
| Option | Default Value | Description |
|---|---|---|
| host | The host of the host running the server | |
| port | The port of the host running the server | |
| address | The address (host:port) of the host running the server | |
| timeout | Number of seconds before connection times out (default=10) | |
| target | Target to use (lookup connection info from config) | |
| retry | Number of times ti retry a failed connection attempt (default=2) | |
| retries | legacy version of retry | |
| source-host | Source/sender host name (default is auto which means use the name of the actual host) | |
| sender-host | Source/sender host name (default is auto which means use the name of the actual host) | |
| command | The name of the command that the remote daemon should run | |
| argument | Set command line arguments | |
| separator | Separator to use for the batch command (default is | |
| batch | Add multiple records using the separator format is: command | |
| certificate | The client certificate to use | |
| dh | The DH key to use | |
| certificate-key | The private key belonging to the client certificate (when it is not in the certificate file itself) | |
| certificate-format | Client certificate format | |
| ca | The certificate authority the server certificate is verified against | |
| verify | How to verify the server certificate. Comma separated list of options: none, peer (or certificate), peer-cert, fail-if-no-cert (or fail-if-no-peer-cert, client-certificate). For a self signed certificate use peer-cert and point –ca at that certificate; none leaves the connection encrypted but the server unauthenticated, so an on-path attacker can impersonate it undetected. | |
| allowed-ciphers | The OpenSSL cipher list the connection is restricted to | |
| ssl | true | Initial an ssl handshake with the server. |
ssl:
Initial an ssl handshake with the server.
Default Value: true
This command also accepts the standard help options: help, help-pb, show-default, help-short.
Configuration¶
| Path / Section | Description |
|---|---|
| /settings/check_mk/client | CHECK MK CLIENT SECTION |
| /settings/check_mk/client/handlers | CLIENT HANDLER SECTION |
| /settings/check_mk/client/scripts | LUA SCRIPTS |
| /settings/check_mk/client/targets | REMOTE TARGET DEFINITIONS |
| /settings/default | Default values |
CHECK MK CLIENT SECTION ¶
Section for check_mk active/passive check module.
| Key | Default Value | Description |
|---|---|---|
| channel | CheckMK | CHANNEL |
| script root | Script root |
# Section for check_mk active/passive check module.
[/settings/check_mk/client]
channel=CheckMK
CHANNEL ¶
The channel to listen to.
| Key | Description |
|---|---|
| Path: | /settings/check_mk/client |
| Key: | channel |
| Default value: | CheckMK |
Sample:
[/settings/check_mk/client]
# CHANNEL
channel=CheckMK
Script root ¶
The folder this module’s scripts live in: ${scripts} by default (empty, or `default`). `fleet` is ${fleet-folder}/scripts, where the fleet sync stages a bundle’s `scripts/` entries - a bundle that ships scripts sets this to `fleet` and refers to them as `scripts\
| Key | Description |
|---|---|
| Path: | /settings/check_mk/client |
| Key: | script root |
| Default value: | N/A |
Sample:
[/settings/check_mk/client]
# Script root
script root=
CLIENT HANDLER SECTION ¶
This is a section of objects. This means that you will create objects below this point by adding sections which all look the same.
LUA SCRIPTS ¶
Lua scripts to load, as <alias> = <file> (resolved under the script root, e.g. scripts/lua/). A script registers a client callback with check_mk.client(<function>) to process the agent output fetched from a remote check_mk agent.
This is a section of objects. This means that you will create objects below this point by adding sections which all look the same.
REMOTE TARGET DEFINITIONS ¶
This is a section of objects. This means that you will create objects below this point by adding sections which all look the same.
Keys:
| Key | Default Value | Description |
|---|---|---|
| address | TARGET ADDRESS | |
| allow host override | false | ALLOW HOST OVERRIDE |
| allowed ciphers | ALLOWED CIPHERS | |
| ca | ${ca-path} | CA |
| certificate | SSL CERTIFICATE | |
| certificate format | CERTIFICATE FORMAT | |
| certificate key | SSL CERTIFICATE | |
| dh | DH KEY | |
| host | TARGET HOST | |
| port | TARGET PORT | |
| retries | 3 | RETRIES |
| timeout | 30 | TIMEOUT |
| use ssl | ENABLE SSL ENCRYPTION | |
| verify mode | peer | VERIFY MODE |
Sample:
# An example of a REMOTE TARGET DEFINITIONS section
[/settings/check_mk/client/targets/sample]
#address=...
allow host override=false
#allowed ciphers=...
ca=${ca-path}
#certificate=...
#certificate format=...
#certificate key=...
#dh=...
#host=...
#port=...
retries=3
timeout=30
#use ssl=...
verify mode=peer
Default values ¶
Default values used in other config sections.
| Key | Default Value | Description |
|---|---|---|
| allowed hosts | 127.0.0.1 | Allowed hosts |
| bind to | BIND TO ADDRESS | |
| cache allowed hosts | true | Cache list of allowed hosts |
| encoding | NRPE PAYLOAD ENCODING | |
| inbox | inbox | INBOX |
| password | Password | |
| script root | Script root | |
| socket queue size | 0 | LISTEN QUEUE |
| thread pool | 10 | THREAD POOL |
| timeout | 30 | TIMEOUT |
| timezone | local | Timezone |
# Default values used in other config sections.
[/settings/default]
allowed hosts=127.0.0.1
cache allowed hosts=true
inbox=inbox
socket queue size=0
thread pool=10
timeout=30
timezone=local
Allowed hosts ¶
A comma separated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | allowed hosts |
| Default value: | 127.0.0.1 |
Sample:
[/settings/default]
# Allowed hosts
allowed hosts=127.0.0.1
BIND TO ADDRESS ¶
Allows you to bind server to a specific local address. This has to be a dotted ip address not a host name. Leaving this blank will bind to all available IP addresses.
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | bind to |
| Default value: | N/A |
Sample:
[/settings/default]
# BIND TO ADDRESS
bind to=
Cache list of allowed hosts ¶
If host names (DNS entries) should be cached, improves speed and security somewhat but won’t allow you to have dynamic IPs for your Nagios server.
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | cache allowed hosts |
| Default value: | true |
Sample:
[/settings/default]
# Cache list of allowed hosts
cache allowed hosts=true
NRPE PAYLOAD ENCODING ¶
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | encoding |
| Advanced: | Yes (means it is not commonly used) |
| Default value: | N/A |
Sample:
[/settings/default]
# NRPE PAYLOAD ENCODING
encoding=
INBOX ¶
The default channel to post incoming messages on
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | inbox |
| Default value: | inbox |
Sample:
[/settings/default]
# INBOX
inbox=inbox
Password ¶
Password an inbound caller has to present. Stored hashed (pbkdf2-sha256$…) when written by `nscp web install` or `nscp web password –set`; a clear-text value written by hand is still accepted, and is hashed in place when re-set. This is a password to verify against, not key material: NSCA encrypts with its shared secret instead of verifying it, so it keeps its own key under /settings/NSCA/server (or the NSCAClient default target) and never reads this one.
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | password |
| Default value: | N/A |
Sample:
[/settings/default]
# Password
password=
Script root ¶
The folder this module’s scripts live in: ${scripts} by default (empty, or `default`). `fleet` is ${fleet-folder}/scripts, where the fleet sync stages a bundle’s `scripts/` entries - a bundle that ships scripts sets this to `fleet` and refers to them as `scripts\
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | script root |
| Default value: | N/A |
Sample:
[/settings/default]
# Script root
script root=
Script root ¶
The folder this module’s scripts live in: ${scripts} by default (empty, or `default`). `fleet` is ${fleet-folder}/scripts, where the fleet sync stages a bundle’s `scripts/` entries - a bundle that ships scripts sets this to `fleet` and refers to them as `scripts\
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | script root |
| Default value: | N/A |
Sample:
[/settings/default]
# Script root
script root=
LISTEN QUEUE ¶
Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts.
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | socket queue size |
| Advanced: | Yes (means it is not commonly used) |
| Default value: | 0 |
Sample:
[/settings/default]
# LISTEN QUEUE
socket queue size=0
THREAD POOL ¶
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | thread pool |
| Advanced: | Yes (means it is not commonly used) |
| Default value: | 10 |
Sample:
[/settings/default]
# THREAD POOL
thread pool=10
TIMEOUT ¶
Timeout (in seconds) when reading packets on incoming sockets. If the data has not arrived within this time we will bail out.
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | timeout |
| Default value: | 30 |
Sample:
[/settings/default]
# TIMEOUT
timeout=30
Timezone ¶
Timezone used to render dates such as boot time. Accepts ‘local’ (default), ‘utc’, or any POSIX TZ string parseable by Boost.Date_time (e.g. ‘MST-07’ or ‘EST-05EDT,M3.2.0,M11.1.0’).
| Key | Description |
|---|---|
| Path: | /settings/default |
| Key: | timezone |
| Advanced: | Yes (means it is not commonly used) |
| Default value: | local |
Sample:
[/settings/default]
# Timezone
timezone=local