Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

Of course, it is possible to download the agents for Linux/Windows/etc, not only via the browser but also by getting them via wget and the REST API.

LAST TESTED ON CHECKMK 2.2.0P1

Step-by-step guide

Prerequisites needed: a user with sufficient rights (the automation user would do out of the box), Checkmk's server hostname (or IP), the site which holds the agent, and the agent you want to download (i.e., OS & hash).

The easiest way for the latter is to navigate to the Agents section in Checkmk and hover the cursor over the installation package:


If you're not able to fetch the hash via the browser, you can access it via CLI: 

root@linux# su - mysite
OMD[mysite]:~$ ls var/check_mk/agents/linux_deb/packages/
1ae46a9ab42f290b  1ae46a9ab42f290b.conf  1ae46a9ab42f290b.sig  8107877152463cf2  8107877152463cf2.conf  8107877152463cf2.sig

wget

As you can see, the HTTP call in the above screenshot is almost complete, so you can right-click on the package and say (depending on the browser): "Copy link" and then create the wget link out of it:


wget "http(s)://<checkmkhost>/<site>/check_mk/download_agent.py?hostname=<hostname>&hash=c9394c3914cc6982&os=linux_tgz&_username=automation&_secret=<automation_secret>" -O agent.deb


httpie, download by the hash value

Install httpie on the system where you want to download the agent.

Create a script with the following content:

#!/bin/bash
HOST_NAME="<checkmk_server>"
SITE_NAME="<sitename>"
API_URL="http://$HOST_NAME/$SITE_NAME/check_mk/api/1.0"
 
USERNAME="automation"
PASSWORD="<automation_secret>"
 
http --json GET "$API_URL/domain-types/agent/actions/download_by_hash/invoke" \
    "Authorization: Bearer $USERNAME $PASSWORD" \
    "Accept: application/octet-stream" \
    agent_hash=="<hash<"\
    os_type=="linux_deb" \
    --download


httpie, download by hostname

Create a script with the following content (host_name in the third section means the host for which the agent is for):

#!/bin/bash
HOST_NAME="<checkmk_server>"
SITE_NAME="<sitename>"
API_URL="http://$HOST_NAME/$SITE_NAME/check_mk/api/1.0"
 
USERNAME="automation"
PASSWORD="<automation_secret>"
 
http --json GET "$API_URL/domain-types/agent/actions/download_by_host/invoke" \
    "Authorization: Bearer $USERNAME $PASSWORD" \
    "Accept: application/octet-stream" \
    host_name=="localhost"\
    os_type=="linux_deb" \
    --download



  • No labels