February 19. 2010
When you call check_mk, you have to specify exactly
one of the following major operating modes:
Short Option | Long Option | Arguments | Mode |
| (none) | | HOSTNAME [IPADDRESS] |
Check mode: performs and immediate check on a host. Required argument is the name of the
host. If the hostname is not resolvable into an IP address via /etc/hosts or
DNS you can specify its IP address as an additional argument. This is the preferred
way when check_mk is called by Nagios and if you do not use precompiled host checks.
The results of the
check are not displayed until you use the option -v. But the results are
sent to Nagios via its command pipe - unless you suppress this with the option
-n. The option -p - if used together with -v
also displays performance data of the checks.
The exit status of check_mk in Check mode adhers to the Nagios convention
for checks: 0 means OK, 1 means warning, 2 means critical and 3 means unknown. |
| -I | | CHECKTYPE(S) [HOST(S)] | Does
in Inventory on one or all hosts. One argument is required:
the check types to make inventory for. Multiple types are separated with
commas (for example df,multipath,md). Alternatively you can
use alltcp which means "all non-SNMP checks".
If you do not specify a hostname, the inventory will be done on all
hosts. Multiple hostnames are separated by spaces. Example: check_mk -I df,multipath hostab1 hostab2
|
| --check-inventory | HOSTNAME |
Checks if an inventory of HOSTNAME would yield new checks. Behaves like
a standard Nagios plugin: Outputs one line of text and exits with
0, 1, 2 or 3. Please look at Inventory Checks for details. |
| -H | | |
Outputs Nagios configuration for all hosts. For each host one define host {...}
is being output to the standard output. You might want to redirect that into
a file, for example with check_mk -H > check_mk_hosts.cfg |
| -S | | | Like -H but outputs
the service definitions for Nagios (and also service dependencies, if you
have defined any). |
| -HS | | | Outputs hosts and services at once. This
is conveniant if you do not need to have seperate output files. |
| --timeperiods | | Outputs Nagios timeperiods definitions
(if define_timeperiods is set in main.mk). |
| -C | --compile | | Creates one specialized Python executable
for each host and byte compiles that. The Python source code and the byte compiled files are created in
the directory precompiled which is usually located under /var/lib/check_mk.
Those files are called by Nagios for checking this hosts. This is the default method.
Using precompiled host checks is much faster then doing checks by calling check_mk,
but does the same. The precompiled file has embedded all code and configuration that
is needed for the actual check. It is completely standalone and does not depend on any
other configuration or Python file. The precompiled check accept only one option: -v.
You do not need to specify an IP address when checking: it is compiled into the check.
After changing configuration files, check parameters in autocheck files or doing
an inventory you always needs to call check_mk -C in order to recreated the
precompiled host checks.
|
| -U | --update | | This is a convenciance option
that does the same as -HS and -C. The output of -HS and --timeperiods
is not written to stdout but into a file. The default name of that file is check_mk_objects.cfg.
It is created in a directory specified at setup - usually directly where it belong: in the Nagios objects
directory. So after each change you just have to call: check_mk -C && /etc/init.d/nagios restart.
You can override the complete path to the file in main.mk with the configuration
variable nagios_objects_file. |
| -R | --restart | | This option is even more
conveniant: It creates a new Nagios configuration just as -HS. Then it does a
Nagios configuration check (by calling Nagios with the option -v). Only if that
check is successfull, the host checks will be precompiled (like option -C) and
Nagios is restarted (by calling its startscript with restart).
If the configuration
check fails, the old Nagios configuration will be restored and no precompilation will
be done. Thus the current configuration of Nagios keeps running. |
| -d | | HOSTNAME | Debug: Get and print output from agent.
This mode fetches the complete output from the check_mk_agent running on HOSTNAME and shows its output.
The default way is by connecting to TCP port 6556, but you might have specified a datasource program
for that host, which will be honored by -d.
|
| --backup | FILENAME | Creates a backupfile FILENAME containing
all configuration and runtime data of your check_mk installation. |
| --restore | FILENAME | Restores the backupfile FILENAME which
was previously created with --backup on your or any other installation of check_mk. |
| --flush | [HOST(S)] | 1.1.3 Delete volatile runtime data
belonging to the specified hosts. If no host is specified, all runtime data will deleted.
This includes performance counters, cache files and stored logfiles. Inventorized
checks will not be deleted. |
| --list-hosts | [HOSTGROUP(S)] | Prints out all hosts. If
you specify one or more hostgroups then just the hosts of those groups are printed. The
output is plain, so that it can easily processed in scripts. |
| --list-tag | [TAG(S)] | Prints out all hosts have certain
tags. If you do not specify any tag then all hosts are printed. If you specify more than
one tag then only those hosts are listed that have all specified tags. |
| -D | --dump | [HOST(S)] | Dumps all configuration information
about all or only about one or more specified hosts. The output is useful for debugging your configuration. |
| -L | --list-checks | | Output a list of all check types
that are supported by your version of check_mk. |
| -M | --man | CHECKTYPE | Shows the builtin manual page for
a specified check type. Currently not all check types have manual pages. |
| --paths | | List various installation, configuration and data
paths of Check_MK and Nagios. |
| -X | --config-check | | Read your configuration files and check them for
invalid variables. The exit code of check_mk is 1 in case of an error and otherwise 0.
Note: Custom variables should be prefixed with _. |
| -V | --version | | Prints your version of check_mk and exists. |
| -h | --help | | Prints a short help of all options and exists. |
Short Option | Long Option | Argument | Effect |
| -v | | | Makes the output of several operations more verbose. This is
also the only option the precompiled checks recognize. |
| -p | | | Also shows
the checks' performance data (only in check mode and together with -v). |
| -n | | | Only in check mode: dry run - do not send data to
Nagios, do not update stored counters. You usually combine this with -v in check mode for debugging. |
| -c | | FILE | Read configuration from FILE instead of the
standard main.mk. This is useful for testing alternativ versions of your main.mk file.
The conf.d directory is searched in the same directory as FILE. See Configuration files for more information about how the configuration files are read. |
| --cache | | | Force usage of cache files if present: In check
mode the output from the agent is always stored in a cache file (if running with the same user as Nagios).
That cache file is only used in inventory mode. With this option you can force check_mk to use an existing
cache file and thus prevent contacting the agent. |
| --no-tcp | | | This is similar to --cache but
suppresses contacting the agent even if no cache file is present. |
| --no-cache | | | In inventory mode check_mk uses data from
cached agent outputs from previous checks if present - regardless of their age. This option forces check_mk
to get fresh information from the agent even if a cache file is present.
While this might be useful for inventorizing single hosts
it can be deadly (in terms of execution time) for a large number of hosts. |
| --fake-dns | IPADDRESS | Suppresses hostname resolution in general
and forces all hosts to have IP address IPADDRESS. This has the effect that for all configured hosts only one
and the same real host is contacted. This allows you to simulate a large number of hosts or test the creation of Nagios
configuration files for a main.mk not matching your existing hosts. |
| --debug | | This options help when looking for
error in the Python code of the module or the checks. It prevents catching exceptions. Any
exception will abort the program and display a complete track trace. |