Gurusankar
(Gurusankar)
February 23, 2026, 12:23pm
1
Hi All,
Greetings!
I am trying to create a custom REST API integration which needs to fetch the HW/SW information of the hosts under a selective Host Folder.
host_inv_api is working fine but i want to make this work with REST API.
Thank you,
Warm Regards,
Guru
BH2005
(Bernd Holzhauer)
February 24, 2026, 5:27am
2
Gurusankar:
I am trying to create a custom REST API integration which needs to fetch the HW/SW information of the hosts under a selective Host Folder.
host_inv_api is working fine but i want to make this work with REST API.
Option 1 use the CMDBSYNCER
CMDBsyncer Documentation
Option 2
is a two-step approach:
Step 1: Retrieve the hosts from the desired folder via the REST API.
Step 2: Fetch the inventory data for these specific hosts using host_inv_api.py.
This combines the best of both worlds and remains a stable solution in version 2.4.
example
SITE="mysite"; SERVER="192.168.1.10"; USER="automation"; PASS="secret"
BASE="https://$SERVER/$SITE/check_mk"
# Step 1: getting hosts from folder
HOSTS=$(curl -s -G \
-H "Authorization: Bearer $USER $PASS" \
-H "Accept: application/json" \
--data-urlencode "folder=linux~debian" \
--data-urlencode "recurse=true" \
"$BASE/api/1.0/domain-types/host_config/collections/all" \
| python3 -c "import sys,json; print(' '.join(h['id'] for h in json.load(sys.stdin)['value']))")
echo "Hosts: $HOSTS"
# Step 2: Inventory inventory for this hosts
HOST_JSON=$(python3 -c "import json,sys; print(json.dumps({'hosts': sys.argv[1:]}))" $HOSTS)
curl -s -G \
-H "Authorization: Bearer $USER $PASS" \
--data-urlencode "output_format=json" \
--data-urlencode "request=$HOST_JSON" \
"$BASE/host_inv_api.py" | python3 -m json.tool
I have a script for this
CMK-exchange/helper_scripts/inv_hosts_from_folder.py at main ยท bh2005/CMK-exchange
1 Like
Gurusankar
(Gurusankar)
February 24, 2026, 7:59am
3
Hallo Bernd,
Thank you so much for your help!.
Best Regards,
Guru
BH2005
(Bernd Holzhauer)
February 24, 2026, 8:04am
4
no prob โฆ but keep in mind:
# Folderpath in CheckMK-Notation:
# Root-Folder โ ""
# /linux โ "linux"
# /linux/debian โ "linux~debian"
# /locations/berlin โ "locations~berlin"
if all fixed mark as solved โฆ
Greetz Bernd
1 Like
thl-cmk
February 24, 2026, 9:12am
5
@Gurusankar if you want to fetch the inventory data via REST-API you can use the Monitoring โ Host status endpoint and fetch the entire HW/SW inventory. Basically this is a Live status query via REST-API.
http(s)://<your-cmk-server>:<port>/<your-site-name>/check_mk/api/1.0/domain-types/host/collections/all
Cheers
Thomas
2 Likes
Gurusankar
(Gurusankar)
February 24, 2026, 9:33am
6
Hello Thomas,
Thank you so much for your help!
Best Regards,
Guru
Sara
February 24, 2026, 6:06pm
7
Hello!
If one of the answers helped you solve your question, please mark it as the solution. This way, you thank the person who helped you and also indicate that the question has been resolved. This, in turn, helps others who come across the same question.
Thank you!
1 Like