Hi there
I am currently building a new Check MK Instance where Foreman knows which Servers exist, that need to be monitored.
My goal is that as soon as the Server is created in Foreman, the Server is also created in Check MK, and if the Server is deleted in Foreman, it is also deleted in Check MK.
Both Check MK and Foreman do have APIs, now the question is, how to link the APIs together.
Best way would be, that Check MK could ask the Foreman API which servers exists, gets a list of existing Servers in Forman, which is then processed in Check MK.
I have not found a “Discovery Feature” for Hosts in Check MK yet.
What is the state of the Art to add and delete host automatically?
I know, that i can write a Script that does all this, but the question is, does Check MK have some sort of automation that asks a API, that already exists?
In my bigger automated systems I do it with a little bit of clue code. A script is collecting the hosts from cmk and the data source (foreman in your case) compare some things like name or other attributes and then decides if it only need to modify a host or create/delete a host.
The data source is different from system to system. One time it is a CSV file the next time it is a CMDB like i-doit.
Dynamic Host Configuration is the thing i was looking for, thank you!
I just could not see it, because for testing i was using the RAW Edition.
So Solution, i need to change to the Free edition so i have all features, including Dynamic Host Configuration.
@Dirk Yes I am, thank you.
I want to test if everything works, and create the Scripts, before I buy the Licence.
Do you know if there is any documentation on how to implement a custom piggyback datasource?
Or should i just try to change an existing one?
Another possibility would be to write some sort of connector between the two APIs. Like a cronjob that runs every minute or so that asks both the Foreman-API and the Checkmk-Web-API for their respective list of hosts. Then it calculates the differences between these two lists (e.g. new_hosts = F-List - C-List and vanished_hosts = C-List - F-List) and eventually calls the Checkmk-API to create the missing and delete the vanished hosts.
This is basically the same thing @andreas-doehler suggested. It would mimick the DCD a bit and (AFAIK) would run with the raw edition as well, which might be an issue.
@Dirk Yes i do already have a Script that does this, except it generates the .mk files, instead of using the API to create hosts. But this Script is big and complicated, so i need to find out, if it is easier to change the Script to use the API, but thats not the prettiest solution, or to create a Piggiback Datasource, that does the same. But the Piggyback Datasource still needs a script to get the list of servers.