Checkmk is is an open-source monitoring solution designed to monitor the availability and performance of your infrastructure. This guide will show you how to deploy it in your lab using Docker, and monitor your servers with it.
Prerequisites #
- A server with Docker installed
- A reverse proxy (Traefik)
- A machine to monitor
1. Deploying Checkmk #
We will be deploying Checkmk in Docker. To do so, I recommend using the following compose file.
# /opt/checkmk/compose.yaml
---
services:
checkmk:
image: checkmk/check-mk-raw:2.4.0-latest
container_name: checkmk
environment:
- TZ=Europe/London # set this to your timezone
ports:
- 8000:8000
tmpfs:
- /opt/omd/sites/cmk/tmp:uid=1000,gid=1000
volumes:
- /etc/localtime:/etc/localtime:ro
- data:/omd/sites:rw
labels:
- traefik.enable=true
- traefik.http.services.checkmk.loadbalancer.server.port=5000
- traefik.http.routers.checkmk.entrypoints=websecure
- traefik.http.routers.checkmk.rule=Host(`checkmk.internal.yourdomain.here`) # change this to your domain
- traefik.http.routers.checkmk.tls=true
- traefik.http.routers.checkmk.tls.certresolver=letsencrypt-prod # change this to your certificate resolver
networks:
- traefik
restart: unless-stopped
volumes:
data:
networks:
traefik:
external: true
This example uses Traefik, which I HIGHLY recommend using.
2. Initial Setup #
You can now start the container
docker compose up -d
Then wait for it to start. (periodically running docker compose ps
until the status is healthy)
Once the container has started, you can check for the default admin credentials.
docker compose logs
The output will contain something like this:
checkmk | Created new site cmk with version 2.4.0p11.cre.
checkmk |
checkmk | The site can be started with omd start cmk.
checkmk | The default web UI is available at http://eed2042d754d/cmk/
checkmk |
checkmk | The admin user for the web applications is cmkadmin with password: 820b059d
checkmk | For command line administration of the site, log in with 'omd su cmk'.
checkmk | After logging in, you can change the password for cmkadmin with 'cmk-passwd cmkadmin'.
You can navigate to the web-ui through whatever domain you configured in your reverse proxy and login with the username cmkadmin
and the password that is in the logs.
Once you are in the web-ui, you can change the password for your user at https://checkmk.internal.yourdomain.here/cmk/check_mk/index.py?start_url=%2Fcmk%2Fcheck_mk%2Fuser_change_pw.py
3. Monitoring Machines #
When it comes to monitoring your machines, there are two ways of doing so. The Checkmk agent and SNMP. This guide will show you how to use both but will not show you how to install and setup SNMP on your machines.
The Checkmk Agent #
To monitor machines with the agent, I recommend deleting the default registration user, and creating a new one with exactly the settings we need for registering machines.
Creating the Registration User #
To create a user for registration, head over to Setup -> Users -> Users.
Delete the default registration user, and click add user.
I called my user registration
and gave it the Agent registration user
role. make sure you take note of the password you give it, you will need it shortly.
Installing the Agent #
To install the agent, you can go to Setup > Agent > Linux and download the agent’s package to your server, for example the .deb
for debian based operating systems.
Example download command:
wget https://checkmk.internal.dontddos.me/cmk/check_mk/agents/check-mk-agent_2.4.0p11-1_all.deb
You can then install with this command:
dpkg -i check-mk-agent_2.4.0p11-1_all.deb
Registering the Machine #
Before we can register the machine, we must first create a host in Checkmk, to do this, go to Setup -> Hosts -> Hosts and then click add host
.
Give it a hostname and select the box next to IPv4 and set the IP to that of your machine. then click save and run service discovery
. Regardless of what you see on the next screen, on the machine you want to monitor, run the following command
cmk-agent-ctl register --hostname REPLACE_WITH_HOSTNAME --server checkmk.internal.dontddos.me:8000 --site cmk --user registration
When asked to accept the certificate, press enter, and when prompted for the password for the registration user, paste it in.
You should then see that registration was successful.
Monitoring Services #
You can now go back the the web-ui and click rescan
. You should see a bunch of services, all with an ok state. If so, click Accept All
.
SNMP #
To monitor a machine with SNMP, head over to Setup -> Hosts -> Hosts and then click add host
. Give it a host name, set the IPv4, tick the box next to Checkmk agent / API integrations
, and set its value to No API integrations, No Checkmk agent
, then check the box next to SNMP
and configure it as needed.
Done #
If all went well, you can now monitor your machines using the Checkmk agent and SNMP.