Managing the addition and removing of the dynamic hosts

So, in our project, people provision hosts(linux and windows) using terraform. So, its like:

  1. The hosts gets created (terraform apply)
  2. The agent gets installed as part of the startup script.
  3. Then we manually do a network scan and add the hosts to Checkmk.
  4. Depending on their use-case, they may keep the host or add/remove it accordingly multiple times. Sometimes the IP gets changed but the hostname remains the same.

How to handle this type of scenario in Checkmk ? I was thinking of avoiding this manual scanning and adding hosts and instead use the startup script with a standard automation user to add hosts to WATO and then delete the host when anyone does a “terraform destroy” but have no experience with this. Any ideas how to get started in this direction ?

Or is Checkmk has already in place this ability to handle dynamic setup ?

Depending on which version of checkmk you operate, indeed it can handle dynamic configuration through piggyback data. See https://checkmk.com/cms_dcd.html. This is not exactly your usecase but you may setup some mechanism that collects the agent output from those dynamic hosts and puts them into a spoolfile (decorated with the hostname).
Once checkmk encounters such piggyback data (and the dynamic configuration daemon is properly configured), the hosts will appear and dissappear automatically in checkmk.
Or make the dynamic hosts send their agent output (via cron) to the checkmk server (as piggyback data).

Either use DCD (if you get host data via piggyback) or use the API to create the hosts: https://checkmk.com/cms_web_api.html

The API will be rewritten in the next version to be REST-based: https://blog.checkmk.com/checkmk-conference-6-one-api-to-rule-them-all

Thank you Dirk and Robert. I am using Check 1.5.0p24 and also have a working 1.6.0p12(that I recently upgraded from 1.5.0p24). So, with the DCD, can I also make sure that the performance data and any rules associated with the host also gets deleted or its just the addition/deletion of hosts ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.