check_mk man page

check_mk — command line utility for managing Check_MK

Synopsis

check_mk [GLOBAL OPTIONS] [MODE] [MODE OPTIONS] [ARGUMENTS...]

Description

check_mk (or its alias cmk) is a command line utility for managing some aspects of the Check_MK Monitoring System. It can be used for diagnosis, for automating things in scripts and for doing some tasks more efficiently than with the web based WATO.

Generic Options

The following options work in all modes and all situations.

-v

More verbose output. In good old Unix tradition check_mk only outputs texts if something goes wrong. By using -v you can get some more information about what's going on.

-vv

Even more vebose output. Some operations give even more details when this options is used.

--debug

Disables the intern exception handling in Check_MK and let all Python exceptions through. That way you can see the exact location in the code where the actual problem is. This helps finding problems in self written check plugins.

Service Discovery

cmk [--checks=CHECK_TYPE1,CHECK_TYPE2,...] -I|-II [HOSTS...]

The options -I and -II do service discovery. Check_MK will analyse the agent output of the specified hosts (or all hosts if none are specified) and automatically create monitored services where it does make sense. While -I only creates new services and keeps the existing ones untouched, -II first removes all existing services before staring the discovery.

The option --checks= restricts the option to a list of check types (e.g. --checks=Bdf,diskstat).  When combined with the mode -II only checks of the specified types are be removed and rediscovered.

When no hosts are specified then Check_MK will do a discovery for all hosts that are defined in your configuration. In order to speed this operation up no actual data is being fetched from the hosts but cached agent data will be used. When you specify host names then fresh data is fetched from these.

Ad Hoc Checking

cmk [-n] [-p] [--checks=CHECK_TYPE1,CHECK_TYPE2,...] -v HOST

This does an ad hoc checking of the host HOST via Check_MK. HOST must be a host that is configured in Check_MK. Check_MK does the same like in real monitoring - it fetches data from the agent and computes the result of all services. Then it outputs each result and sends the result to the monitoring core.

-p Also prints metrics data of the services.

-n Prevents the check results from being sent to the monitoring core. That way

-v Outputs the results of the passive checks on the terminal. Without this option Check_MK behaves like a classical monitoring plugin: it outputs one line of text (essentially the output of the Check_MK service) and exists with 0, 1, 2 or 3 (OK, WARN, CRIT, UNKNOWN). This was how Nagios called Check_MK in ancient times.

The option --checks= restricts the option to a list of check types (e.g. --checks=Bdf,diskstat).  That way only a reduced set of service is being checked. This is useful for testing and debugging a check plugin.

check_mk

cmk [-n] [-v] [-p] HOST [IPADDRESS]  check all services on HOST
cmk -I [HOST ..]                     inventory - find new services
cmk -II ...                          renew inventory, drop old services
cmk -N [HOSTS...]                    output Nagios configuration
cmk -B                               create configuration for core
cmk -C, --compile                    precompile host checks
cmk -U, --update                     precompile + create config for core
cmk -O, --reload                     precompile + config + core reload
cmk -R, --restart                    precompile + config + core restart
cmk -D, --dump [H1 H2 ..]            dump all or some hosts
cmk -d HOSTNAME|IPADDRESS            show raw information from agent
cmk --check-discovery HOSTNAME       check for items not yet checked
cmk --discover-marked-hosts          run discovery for hosts known to have changed services
cmk --update-dns-cache               update IP address lookup cache
cmk -l, --list-hosts [G1 G2 ...]     print list of all hosts
cmk --list-tag TAG1 TAG2 ...         list hosts having certain tags
cmk -L, --list-checks                list all available check types
cmk -M, --man [CHECKTYPE]            show manpage for check CHECKTYPE
cmk -m, --browse-man                 open interactive manpage browser
cmk --paths                          list all pathnames and directories
cmk -X, --check-config               check configuration for invalid vars
cmk --backup BACKUPFILE.tar.gz       make backup of configuration and data
cmk --restore BACKUPFILE.tar.gz      restore configuration and data
cmk --flush [HOST1 HOST2...]         flush all data of some or all hosts
cmk --donate                         Email data of configured hosts to MK
cmk --snmpwalk HOST1 HOST2 ...       Do snmpwalk on one or more hosts
cmk --snmptranslate HOST             Do snmptranslate on walk
cmk --snmpget OID HOST1 HOST2 ...    Fetch single OIDs and output them
cmk --scan-parents [HOST1 HOST2...]  autoscan parents, create conf.d/parents.mk
cmk -P, --package COMMAND            do package operations
cmk --localize COMMAND               do localization operations
cmk --handle-alerts                  used to handle alerts from core
cmk --notify                         used to send notifications from core
cmk --create-rrd [--keepalive|SPEC]  create round robin database (only CEE)
cmk --convert-rrds [--split] [H...]  convert exiting RRD to new format (only CEE)
cmk --compress-history FILES...      optimize monitoring history files for CMC
cmk --handle-alerts                  alert handling, always in keepalive mode (only CEE)
cmk -i, --inventory [HOST1 HOST2...] Do a HW/SW-Inventory of some ar all hosts
cmk --inventory-as-check HOST        Do HW/SW-Inventory, behave like check plugin
cmk -A, --bake-agents [-f] [H1 H2..] Bake agents for hosts (not in all versions)
cmk --cap pack|unpack|list FILE.cap  Pack/unpack agent packages (not in all versions)
cmk --show-snmp-stats                Analyzes recorded Inline SNMP statistics
cmk -V, --version                    print version
cmk -h, --help                       print this help

OPTIONS:
 -v             show what's going on
 -p             also show performance data (use with -v)
 -n             do not submit results to core, do not save counters
 -c FILE        read config file FILE instead of %s
 --cache        read info from cache file is present and fresh, use TCP
                only, if cache file is absent or too old
 --no-cache     never use cached information
 --no-tcp       for -I: only use cache files. Skip hosts without
                cache files.
 --fake-dns IP  fake IP addresses of all hosts to be IP. This
                prevents DNS lookups.
 --usewalk      use snmpwalk stored with --snmpwalk
 --debug        never catch Python exceptions
 --interactive  Some errors are only reported in interactive mode, i.e. if stdout
                is a TTY. This option forces interactive mode even if the output
                is directed into a pipe or file.
 --procs N      start up to N processes in parallel during --scan-parents
 --checks A,..  restrict checks/inventory to specified checks (tcp/snmp/check type)
 --keepalive    used by Check_MK Mirco Core: run check and --notify
                in continous mode. Read data from stdin and from cmd line.
 --cmc-file=X   relative filename for CMC config file (used by -B/-U)
 --extraoid A   Do --snmpwalk also on this OID, in addition to mib-2 and enterprises.
                You can specify this option multiple times.
 --oid A        Do --snmpwalk on this OID instead of mib-2 and enterprises.
                You can specify this option multiple times.
 --hw-changes=S --inventory-as-check: Use monitoring state S for HW changes
 --sw-changes=S --inventory-as-check: Use monitoring state S for SW changes

NOTES:
 -I can be restricted to certain check types. Write '--checks df -I' if you
 just want to look for new filesystems. Use 'check_mk -L' for a list
 of all check types. Use 'tcp' for all TCP based checks and 'snmp' for
 all SNMP based checks.

 -II does the same as -I but deletes all existing checks of the
 specified types and hosts.

 -N outputs the Nagios configuration. You may optionally add a list
 of hosts. In that case the configuration is generated only for
 that hosts (useful for debugging).

 -U redirects both the output of -S and -H to the file %s
 and also calls check_mk -C.

 -D, --dump dumps out the complete configuration and information
 about one, several or all hosts. It shows all services, hostgroups,
 contacts and other information about that host.

 -d does not work on clusters (such defined in main.mk) but only on
 real hosts.

 --check-discovery make check_mk behave as monitoring plugins that
 checks if an inventory would find new or vanished services for the host.
 If configured to do so, this will queue those hosts for automatic
 discover-marked-hosts

 --discover-marked-hosts run actual service discovery on all hosts that
 are known to have new/vanished services due to an earlier run of
 check-discovery. The results of this discovery may be activated
 automatically if that was discovered.

 --list-hosts called without argument lists all hosts. You may
 specify one or more host groups to restrict the output to hosts
 that are in at least one of those groups.

 --list-tag prints all hosts that have all of the specified tags
 at once.

 -M, --man shows documentation about a check type. If
 /usr/bin/less is available it is used as pager. Exit by pressing
 Q. Use -M without an argument to show a list of all manual pages.

 --backup saves all configuration and runtime data to a gzip
 compressed tar file. --restore *erases* the current configuration
 and data and replaces it with that from the backup file.

 --flush deletes all runtime data belonging to a host. This includes
 the inventorized checks, the state of performance counters,
 cached agent output, and logfiles. Precompiled host checks
 are not deleted.

 -P, --package brings you into packager mode. Packages are
 used to ship inofficial extensions of Check_MK. Call without
 arguments for a help on packaging.

 --localize brings you into localization mode. You can create
 and/or improve the localization of Check_MKs Multisite.  Call without
 arguments for a help on localization.

 --donate is for those who decided to help the Check_MK project
 by donating live host data. It tars the cached agent data of
 those host which are configured in main.mk:donation_hosts and sends
 them via email to donatehosts@mathias-kettner.de. The host data
 is then publicly available for others and can be used for setting
 up demo sites, implementing checks and so on.
 Do this only with test data from test hosts - not with productive
 data! By donating real-live host data you help others trying out
 Check_MK and developing checks by donating hosts. This is completely
 voluntary and turned off by default.

 --snmpwalk does a complete snmpwalk for the specified hosts both
 on the standard MIB and the enterprises MIB and stores the
 result in the directory %s. Use the option --oid one or several
 times in order to specify alternative OIDs to walk. You need to
 specify numeric OIDs. If you want to keep the two standard OIDS
 .1.3.6.1.2.1  and .1.3.6.1.4.1 then use --extraoid for just adding
 additional OIDs to walk.

 --snmptranslate does not contact the host again, but reuses the hosts
 walk from the directory %s.%s

 --scan-parents uses traceroute in order to automatically detect
 hosts's parents. It creates the file conf.d/parents.mk which
 defines gateway hosts and parent declarations.

 -A, --bake-agents creates RPM/DEB/MSI packages with host-specific
 monitoring agents. If you add the option -f, --force then all
 agents are renewed, even if an uptodate version for a configuration
 already exists. Note: baking agents is only contained in the
 subscription version of Check_MK.

 --show-snmp-stats analyzes and shows a summary of the Inline SNMP
 statistics which might have been recorded on your system before.
 Note: This is only contained in the subscription version of Check_MK.

 --convert-rrds converts the internal structure of existing RRDs
 to the new structure as configured via the rulesets cmc_host_rrd_config
 and cmc_service_rrd_config. If you do not specify hosts, then all
 RRDs will be converted. Conversion just takes place if the configuration
 of the RRDs has changed. The option --split will activate conversion
 from exising RRDs in PNP storage type SINGLE to MULTIPLE.

 -i, --inventory does a HW/SW-Inventory for all, one or several
 hosts. If you add the option -f, --force then persisted sections
 will be used even if they are outdated.

Info

November 2015 Check_MK Command line utility