Hello,
I would like to automatically create hosts via the API. Since I never used an API before or automated such things (sorry, I’m a bloody beginner) I’m asking here for help.
My idea was, through my software deployment system I roll out the agent → works
It also registers the agent for TLS via a script, which also works
(“C:\Program Files (x86)\checkmk\service\cmk-agent-ctl.exe” register --hostname %COMPUTERNAME%.DOMAIN.TLD --server HOST.DOMAIN.TLD:8000 --site SITNAME --user automation --password AUTOMATIONPASSWORD)
How can I create the host dynamically from the client where the agent is installed?
Basically just create the host in the folder with the hostname (FQDN like at the agent registration above , no attributes like IP etc…)
And I guess that would also be easily adaptable to Linux.
the easiest way would be to use the cloud edition, that includes an agent with auto registration features that does exactly what you want
Otherwise you can just trigger a powershell script on the monitored host, read its local hostname and create the host via the rest api. Alternatively the software deployment could trigger the script, if you can give it the hostname of the target host.
An example is e.g. this, but there are several examples in this forum.
In the checkmk help (lower left) in the checkmk gui there is the complete API documentation.
Thank you for the help.
After doing a lot of scripting the whole day (partially thanks to Copilot) I got it working
It is primarily for my homelab, so I don’t want the cloud version.
I created 8 scripts, 4 for manual setup, 4 for automatic silent install with more variables
→ All scripts are designed to be run from the host in question. There is a variable which reads the FQDN of the host it is run on (e.g. HOST.AD.DOMAIN.CORP for an AD environment)
1 creates the host in Checkmk
MANUAL:
has variables in it which you have to set (Checkmk data, and the folder where host should be created)
AUTOMATIC:
Basically the same, but shows a popup with link to the folder
2 activates the changes and saves the host
(you have to wait a bit, it shows they are applied, but at the moment of the message the y aren't yet !!!)
-> AUTOMATIC closes after finishing. MANUAL stays open and shows message
3 sets downtime for host during setup
MANUAL:
Shows popup for duration of downtime and comment, afterwards shows link to downtimes of host
AUTOMATIC:
Just sets downtime + comment according to the variables (Downtime variable only accepts hours, so at least one hour)
4 TLS registration
-> AUTOMATIC closes after finishing. MANUAL stays open and shows message
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.