Use REST API for automatic agent deployment

We want to deploy CheckMK agents automatically through Jenkins in our environments. I am exploring the possibilities with the REST API (we use CheckMK 2.0.0p9)
But I have a few questions: As far as I can see, I can’t find an option to obtain the correct agenthash for a particular host. However, I need that hash to download an agent with the API. The only API-call I could find is “Show all agents”, which shows me the available agenthashes. But it doesn’t show the relation between hosts and the hashes. Is there a way to find the correct hash for a specific server?

And when I use the example code for downloading an agent, or even when I use the interactive GUI to test the “download an agent”-call, a HTTP error 500 is returned. I am very sure I use the correct parameters, is it possible that this functionality is not properly implemented yet?

Yes, this is a really annoying idea from the REST API, @LaMi . It should be sufficient to pass the hostname (and os_type) as call parameter to the API to get the agent for the host.

2 Likes

I agree with you. We’ll investigate and improve this.

4 Likes

In the meantime, is there any API call that can be used to find the agent_hash for a host?

FYI: I noticed that release 2.0p18 contains werk 13399: RESTAPI: Endpoint for downloading agent by host name (checkmk.com)

I just installed this release and indeed, I can now download the correct agent with only supplying the hostname and os type!

Thanks dev’s for your awesome work! :slight_smile:

3 Likes

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.