How to use cmcdump

For using the cmcdump filter, we use the lql. Click the following to learn more about Retrieving status data via Livestatus

LAST TESTED ON CHECKMK 2.2.0P1

Table of Contents

Please keep in mind that the cmcdump is only a mirror of your remote site with no access to the remote site. On the central site, you cant configure rules/downtimes/notifications for these so-called shadow hosts.

Getting Started

Background information regarding this subject is available on our:


cmcdump with some examples

One host and service filter

In this example, I will dump the config and use -H and -S for filtering. With -H, I will search for all hosts beginning with the IP-Address 127. After that, I will use the same command (without -C) to dump the state. I only want the Checkmk Service from this host to reduce the result.


Create the config file

OMD[mysite]:~$ cmcdump -C -H "Filter: host_address ~ 127" -S "Filter: description = Check_MK"
# Created by /omd/sites/mysite/bin/cmcdump -C -H Filter: host_address ~ 127 -S Filter: description = Check_MK

shadow_hosts.update({u'localhost3': {u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'check-mk-host-smart!', u'notification_interval': 0, u'process_performance_data': 0, u'notification_period': u'24X7', u'check_command': u'check-mk-host-smart', u'retry_interval': 0.1, u'contact_groups': [], u'flap_detection_enabled': 1, u'alias': u'localhost3', u'parents': [], u'check_interval': 0.1, u'address': u'127.0.0.1', 'services': [{u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'', u'description': u'Check_MK', u'notification_interval': 0, u'process_performance_data': 1, u'notification_period': u'24X7', u'check_command': u'check-mk', u'retry_interval': 1, u'contact_groups': [], u'check_interval': 1, u'custom_variables': {u'NOTIFY_SEVMAP': u'UNKNOWN: 4, CRITICAL: 3, OK: 5, WARNING: 3', u'EC_CONTACT': u'testservice'}, u'max_check_attempts': 1, u'groups': [], u'first_notification_delay': 0, u'flap_detection_enabled': 1}], u'max_check_attempts': 1, u'groups': [u'check_mk'], u'first_notification_delay': 0, u'custom_variables': {u'ADDRESS_FAMILY': u'4', u'TAGS': u'/wato/ add_ip_addresses_1 auto-piggyback cmk-agent ip-v4 ip-v4-only lan no-snmp prod site:mysite tcp', u'NOTIFY_HOST': u'test', u'ADDRESS_4': u'127.0.0.1', u'ADDRESS_6': u'', u'FILENAME': u'/wato/hosts.mk'}}, u'localhost2': {u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'check-mk-host-smart!', u'notification_interval': 0, u'process_performance_data': 0, u'notification_period': u'24X7', u'check_command': u'check-mk-host-smart', u'retry_interval': 0.1, u'contact_groups': [u'all'], u'flap_detection_enabled': 1, u'alias': u'localhost2', u'parents': [], u'check_interval': 0.1, u'address': u'127.0.0.1', 'services': [{u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'', u'description': u'Check_MK', u'notification_interval': 0, u'process_performance_data': 1, u'notification_period': u'24X7', u'check_command': u'check-mk', u'retry_interval': 1, u'contact_groups': [u'all'], u'check_interval': 1, u'custom_variables': {u'NOTIFY_SEVMAP': u'UNKNOWN: 4, CRITICAL: 3, OK: 5, WARNING: 3', u'EC_CONTACT': u'testservice'}, u'max_check_attempts': 1, u'groups': [], u'first_notification_delay': 0, u'flap_detection_enabled': 1}], u'max_check_attempts': 1, u'groups': [u'check_mk'], u'first_notification_delay': 0, u'custom_variables': {u'ADDRESS_FAMILY': u'4', u'TAGS': u'/wato/ add_ip_addresses_1 auto-piggyback cmk-agent ip-v4 ip-v4-only lan no-snmp prod site:mysite tcp', u'NOTIFY_HOST': u'test', u'ADDRESS_4': u'127.0.0.1', u'ADDRESS_6': u'', u'FILENAME': u'/wato/hosts.mk'}}, u'localhost': {u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'check-mk-host-smart!', u'notification_interval': 0, u'process_performance_data': 0, u'notification_period': u'24X7', u'check_command': u'check-mk-host-smart', u'retry_interval': 0.1, u'contact_groups': [u'all'], u'flap_detection_enabled': 1, u'alias': u'localhost', u'parents': [], u'check_interval': 0.1, u'address': u'127.0.0.1', 'services': [{u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'', u'description': u'Check_MK', u'notification_interval': 0, u'process_performance_data': 1, u'notification_period': u'24X7', u'check_command': u'check-mk', u'retry_interval': 1, u'contact_groups': [u'all'], u'check_interval': 1, u'custom_variables': {u'NOTIFY_SEVMAP': u'UNKNOWN: 4, CRITICAL: 3, OK: 5, WARNING: 3', u'EC_CONTACT': u'testservice'}, u'max_check_attempts': 1, u'groups': [], u'first_notification_delay': 0, u'flap_detection_enabled': 1}], u'max_check_attempts': 1, u'groups': [u'host'], u'first_notification_delay': 0, u'custom_variables': {u'ADDRESS_FAMILY': u'4', u'TAGS': u'/wato/ add_ip_addresses_1 auto-piggyback cmk-agent ip-v4 ip-v4-only lan no-snmp prod site:mysite tcp', u'NOTIFY_HOST': u'test', u'ADDRESS_4': u'127.0.0.1', u'ADDRESS_6': u'', u'FILENAME': u'/wato/hosts.mk'}}})


root@mylinuxhost:~# su - mysite -c 'cmcdump -C -H "Filter: host_address ~ 127" -S "Filter: description = Check_MK"> /tmp/remote.mk'
root@mylinuxhost:~# cp /tmp/remote.mk  /omd/sites/myremotesite/etc/check_mk/conf.d/
root@mylinuxhost:~# chown myremotesite. /omd/sites/myremotesite/etc/check_mk/conf.d/
root@mylinuxhost:# su - myremotesite -c 'cmk -O'
OMD[myremotesite]:~$ cmk -O
Generating configuration for core (type cmc)...OK
Packing config...OK
Reloading monitoring core...OK


All host overview


Create the state file

root@mylinuxhost:/omd/sites/myremotesite/etc/check_mk/conf.d# su - mysite -c 'cmcdump -H "Filter: host_address ~ 127" -S "Filter: description = Check_MK"> /tmp/remote.state'
root@mylinuxhost:/omd/sites/myremotesite/etc/check_mk/conf.d# cp /tmp/remote.state /omd/sites/myremotesite/tmp/
root@mylinuxhost:/omd/sites/myremotesite/etc/check_mk/conf.d# chown myremotesite. /omd/sites/myremotesite/tmp/remote.state 
root@mylinuxhost:/omd/sites/myremotesite/etc/check_mk/conf.d# su - myremotesite -c 'unixcat tmp/run/live < tmp/remote.state'


All host overview


 Overview of mysite01 focused on the Check_mk service with the status of OK.

Two hosts and one service filters

In this example, I will dump the config and two -H filter and only one -S filter. With -H, I will search for all hosts beginning with the IP-Address 127 and are a member of the contact group 'all'. To reduce the result, I only want the Checkmk Service from this host. After that, I will use the same command (without -C) to dump the state.

Create the config file

OMD[mysite]:~$ cmcdump -C -H "Filter: host_address ~ 127" -H "Filter: contact_groups ~ all" -S "Filter: description = Check_MK"
# Created by /omd/sites/mysite/bin/cmcdump -C -H Filter: host_address ~ 127 -H Filter: contact_groups ~ all -S Filter: description = Check_MK

shadow_hosts.update({u'localhost2': {u'process_performance_data': 0, u'custom_variables': {u'ADDRESS_FAMILY': u'4', u'TAGS': u'/wato/ add_ip_addresses_1 auto-piggyback cmk-agent ip-v4 ip-v4-only lan no-snmp prod site:mysite tcp', u'NOTIFY_HOST': u'test', u'ADDRESS_4': u'127.0.0.1', u'ADDRESS_6': u'', u'FILENAME': u'/wato/hosts.mk'}, u'check_period': u'24X7', u'notification_interval': 0, u'notification_period': u'24X7', u'retry_interval': 0.1, u'comments': [], u'parents': [], u'first_notification_delay': 0, u'flap_detection_enabled': 1, u'service_period': u'24X7', u'check_command_expanded': u'check-mk-host-smart!', u'notifications_enabled': 1, u'contact_groups': [u'all'], u'groups': [u'check_mk'], u'address': u'127.0.0.1', 'services': [{u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'', u'description': u'Check_MK', u'notification_interval': 0, u'process_performance_data': 1, u'notification_period': u'24X7', u'check_command': u'check-mk', u'retry_interval': 1, u'contact_groups': [u'all'], u'comments': [], u'check_interval': 1, u'custom_variables': {u'NOTIFY_SEVMAP': u'UNKNOWN: 4, CRITICAL: 3, OK: 5, WARNING: 3', u'EC_CONTACT': u'testservice'}, u'max_check_attempts': 1, u'groups': [], u'first_notification_delay': 0, u'flap_detection_enabled': 1}], u'check_command': u'check-mk-host-smart', u'alias': u'localhost2', u'check_interval': 0.1, u'max_check_attempts': 1}, u'localhost': {u'process_performance_data': 1, u'custom_variables': {u'ADDRESS_FAMILY': u'4', u'TAGS': u'/wato/ add_ip_addresses_1 auto-piggyback cmk-agent ip-v4 ip-v4-only lan no-snmp prod site:mysite tcp', u'NOTIFY_HOST': u'test', u'ADDRESS_4': u'127.0.0.1', u'ADDRESS_6': u'', u'FILENAME': u'/wato/hosts.mk'}, u'check_period': u'24X7', u'notification_interval': 0, u'notification_period': u'24X7', u'retry_interval': 1, u'comments': [149], u'parents': [], u'first_notification_delay': 0, u'flap_detection_enabled': 1, u'service_period': u'24X7', u'check_command_expanded': u'check-mk-host-ping!-w 200.00,80.00% -c 500.00,100.00%', u'notifications_enabled': 1, u'contact_groups': [u'all'], u'groups': [u'host'], u'address': u'127.0.0.1', 'services': [{u'check_period': u'24X7', u'service_period': u'24X7', u'notifications_enabled': 1, u'check_command_expanded': u'', u'description': u'Check_MK', u'notification_interval': 0, u'process_performance_data': 1, u'notification_period': u'24X7', u'check_command': u'check-mk', u'retry_interval': 1, u'contact_groups': [u'all'], u'comments': [], u'check_interval': 1, u'custom_variables': {u'NOTIFY_SEVMAP': u'UNKNOWN: 4, CRITICAL: 3, OK: 5, WARNING: 3', u'EC_CONTACT': u'testservice'}, u'max_check_attempts': 1, u'groups': [], u'first_notification_delay': 0, u'flap_detection_enabled': 1}], u'check_command': u'check-mk-host-ping', u'alias': u'localhost', u'check_interval': 1, u'max_check_attempts': 1}})



root@mylinuxhost:# su - mysite -c 'cmcdump -C -H "Filter: host_address ~ 127" -H "Filter: contact_groups ~ all" -S "Filter: description = Check_MK" >/tmp/remote.mk'
root@mylinuxhost:# cp /tmp/remote.mk /omd/sites/myremotesite/etc/check_mk/conf.d/
root@mylinuxhost:# chown myremotesite. /omd/sites/myremotesite/etc/check_mk/conf.d/
root@mylinuxhost:# su - myremotesite -c 'cmk -O'
Generating configuration for core (type cmc)...OK
Packing config...OK
Reloading monitoring core...OK


All host overview with both host in UP status


Create the state file

root@mylinuxhost:# su - mysite -c 'cmcdump  -H "Filter: host_address ~ 127" -H "Filter: contact_groups ~ all" -S "Filter: description = Check_MK" >/tmp/remote.state'
root@mylinuxhost:# cp /tmp/remote.state /omd/sites/myremotesite/tmp/
root@mylinuxhost:# chown myremotesite. /omd/sites/myremotesite/tmp/remote.state 
root@mylinuxhost:# su - myremotesite -c 'unixcat tmp/run/live < tmp/remote.state'


Multiple hosts and services in one query

Create the config file

root@mylinuxhost:# su - mysite -c 'cmcdump -C -H "Filter: host_name ~ (localhost$|Windows_Server)" -H "Filter: contact_groups ~ all" -S "Filter: description ~ (Check_MK$|CPU)">/tmp/remote.mk'
root@mylinuxhost:# cp /tmp/remote.mk  /omd/sites/myremotesite/etc/check_mk/conf.d/
root@mylinuxhost:# chown myremotesite. /omd/sites/myremotesite/etc/check_mk/conf.d/remote.mk 
root@mylinuxhost:# su - myremotesite -c 'cmk -O'
Generating configuration for core (type cmc)...OK
Packing config...OK
Reloading monitoring core...OK



Create the state file

root@mylinuxhost:# su - mysite -c 'cmcdump  -H "Filter: host_name ~ (localhost$|Windows_Server)" -H "Filter: contact_groups ~ all" -S "Filter: description ~ (Check_MK$|CPU)">/tmp/remote.state'
root@mylinuxhost:# cp /tmp/remote.state  /omd/sites/myremotesite/tmp/
root@mylinuxhost:# chown myremotesite. /omd/sites/myremotesite/tmp/remote.state 
root@mylinuxhost:# su - myremotesite -c 'unixcat tmp/run/live < tmp/remote.state'

It's important to remember that the column names used for -H and -S need to be the same. With this command, you'll receive all columns names:

OMD[mysite]:~/bin$ lq "GET columns\nColumns: name\nFilter: table = hosts"

OMD[mysite]:~/bin$ lq "GET columns\nColumns: name\nFilter: table = services"


Use of different column names in Host and Service filters

Some examples:

root@mylinuxhost:# su - mysite -c 'cmcdump -C -O "Filter: name = localhost" -S "Filter: host_name = localhost"'
root@mylinuxhost:# su - mysite -c 'cmcdump  -O "Filter: name = localhost" -S "Filter: host_name = localhost"'

-> Here you will receive all services from localhost, while using the column name and host_name

root@mylinuxhost:# su - mysite -c 'cmcdump  -C -O "Filter: name = localhost" -S "Filter: host_name = localhost" -S "Filter: description = Check_MK"'
root@mylinuxhost:# su - mysite -c 'cmcdump  -O "Filter: name = localhost" -S "Filter: host_name = localhost" -S "Filter: description = Check_MK"'

-> Here you will receive the Checkmk service from localhost, while using the column name, host_name and descritpion

Here I use different column names from the host and service view!


Host check command

If you use Smart-Ping, the hosts can become stale on the central site. In this case, please switch to normal Ping as host check command!

OMD Crontab

log in as a site user

root@mylinuxhost:# su mysite

Create the cron file

OMD[mysite]:~$ cd etc/cron.d/
OMD[mysite]:~$ touch FILENAME
OMD[mysite]:~$ vi Filename

A possible input of the file

*/1 * * * * scp config.mk central@mycentral.mydomain:etc/check_mk/conf.d/remote1.mk
*/1 * * * * sleep 30; cmcdump | ssh at@checkmk "unixcat tmp/run/live"


Reload the crontab

OMD[mysite]:~/etc/cron.d$ omd restart crontab

You need to reload cron after every Change of the file.