CheckMk: Use Docker Compose for CheckMk

CheckMk: Use Docker Compose for CheckMk

CheckMk is a great tool for monitoring. It's quite easy to deploy, and it offers support for monitoring a big range of hardware and software solutions - either through plugins, or out of the box.

To create a CheckMk container, you can use this docker-compose.yml:

services:
  checkmk:
    image: checkmk/check-mk-raw:2.2.0-latest
    tmpfs: /opt/omd/sites/cmk/tmp:uid=1000,gid=1000
    volumes:
      - ./monitoring:/omd/sites
      - /etc/localtime:/etc/localtime:ro
    ports:
      - 5000:5000
      - 8000:8000
    restart: always
This image will only work on x86_64.

Then, the image will be pulled and the container started:

# docker compose pull
# docker compose up -d
[+] Pulling 7/7
 ✔ checkmk Pulled                                                                            243.7s
   ✔ 43f89b94cd7d Pull complete                                                               17.9s
   ✔ c333a7cd7991 Pull complete                                                               18.0s
   ✔ f1a8ddf7a047 Pull complete                                                              100.5s
   ✔ c3b68830a381 Pull complete                                                              110.9s
   ✔ cdb87fce6a90 Pull complete                                                              241.8s
   ✔ c04a97edb62a Pull complete                                                              241.9s
[+] Running 2/2
 ✔ Network checkmk_default      Created                                                        0.6s
 ✔ Container checkmk-checkmk-1  Started                                                        3.2s

The logs show what happens:

# docker compose logs -f
checkmk-1  | ### CREATING SITE 'cmk'
checkmk-1  | Generating configuration for core (type nagios)...
checkmk-1  | Precompiling host checks...OK
checkmk-1  | Adding /opt/omd/sites/cmk/tmp to /etc/fstab.
checkmk-1  | Going to set TMPFS to off.
checkmk-1  | Temporary filesystem already mounted
checkmk-1  | Updating core configuration...
checkmk-1  | Executing post-create script "01_create-sample-config.py"...OK
checkmk-1  | Adding /opt/omd/sites/cmk/tmp to /etc/fstab.
checkmk-1  | Going to set TMPFS to off.
checkmk-1  | Created new site cmk with version 2.2.0p37.cre.
checkmk-1  |
checkmk-1  |   The site can be started with omd start cmk.
checkmk-1  |   The default web UI is available at http://checkmk/cmk/
checkmk-1  |
checkmk-1  |   The admin user for the web applications is cmkadmin with password: XxXxXxXx
checkmk-1  |   For command line administration of the site, log in with 'omd su cmk'.
checkmk-1  |   After logging in, you can change the password for cmkadmin with 'cmk-passwd cmkadmin'.
checkmk-1  |
checkmk-1  | WARNING: You have to execute 'omd update-apache-config cmk' as root to update and apply the configuration of the system apache.
checkmk-1  | WARNING: You have to execute 'omd update-apache-config cmk' as root to update and apply the configuration of the system apache.
checkmk-1  | ### STARTING XINETD
checkmk-1  |  * Starting internet superserver xinetd
checkmk-1  |    ...done.
checkmk-1  | ### STARTING SITE
checkmk-1  | Starting agent-receiver...OK
checkmk-1  | Starting mkeventd...OK
checkmk-1  | Starting rrdcached...OK
checkmk-1  | Starting npcd...OK
checkmk-1  | Starting nagios...OK
checkmk-1  | Starting apache...OK
checkmk-1  | Starting redis...OK
checkmk-1  | Initializing Crontab...OK
checkmk-1  | Temporary filesystem already mounted
checkmk-1  | ### STARTING CRON
checkmk-1  | ### CONTAINER STARTED

Now, CheckMk is available, using the port 5000.

Login is cmkadmin, password can be taken from the log files:

checkmk-1  |   The admin user for the web applications is cmkadmin with password: XxXxXxXx

To install a CheckMk agent, we can use the link from Setup -> Linux -> Packaged Agents. It's available for DEB and RPM based distributions, using Setup -> Windows -> Packaged Agents there's also an MSI package for Windows.

Download links for the agent look like that:

http://<hostname>:5000/cmk/check_mk/agents/check-mk-agent_2.2.0p37-1_all.deb
http://<hostname>:5000/cmk/check_mk/agents/check-mk-agent-2.2.0p37-1.noarch.rpm
http://<hostname>:5000/cmk/check_mk/agents/windows/check_mk_agent.msi

After installation, we can add the host to CheckMk. And monitoring begins...

Subscribe to Martin's Blog

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe