Hey guys,
I spent the last weeks to get comfortable with the REST API, and I get along with it pretty good. (Swagger is awesome!)
Today I stumbled across something, where the API behaves really strange.
This is the curl request I run:
bulk_service_discovery_mon-client-1_company_cloud=$(curl --insecure -X 'POST' \
--header "Authorization: Bearer automation_user $(cat /opt/omd/sites/local/var/check_mk/web/automation_user/automation.secret)" \
'https://monitoring.local.company.toplevel/local/check_mk/api/1.0/domain-types/discovery_run/actions/bulk-discovery-start/invoke' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"hostnames": [
"mon-client-1.company.toplevel",
"mon-client-2.company.toplevel"
],
"mode": "fix_all",
"do_full_scan": true,
"bulk_size": 10,
"ignore_errors": true
}')
echo -e "Execute Bulk service discovery with fix_all.\n"
After running this, the services on the two hostnames I provide get discovered, but they do not get added (like the mode fix_all suggest), I don’t get any changes afterwards for added services or updated tags, etc.
However, running the service discovery via a curl request on https://monitoring.local.company.toplevel/local/check_mk/api/1.0/domain-types/service_discovery_run/actions/start/invoke they get discovered and added to changes - how I want it to behave:
service_discovery_mon-client-1_company_cloud=$(curl --insecure -X 'POST' \
--header "Authorization: Bearer automation_user $(cat /opt/omd/sites/local/var/check_mk/web/automation_user/automation.secret)" \
'https://monitoring.local.company.toplevel/local/check_mk/api/1.0/domain-types/service_discovery_run/actions/start/invoke' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"host_name": "mon-client-1.company.toplevel",
"mode": "fix_all"
}')
echo -e "Run discovery for mon-client-1.company.toplevel with fix_all.\n"
service_discovery_mon-client-2_company_cloud=$(curl --insecure -X 'POST' \
--header "Authorization: Bearer automation_user $(cat /opt/omd/sites/local/var/check_mk/web/automation_user/automation.secret)" \
'https://monitoring.local.company.toplevel/local/check_mk/api/1.0/domain-types/service_discovery_run/actions/start/invoke' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"host_name": "mon-client-2.company.toplevel",
"mode": "fix_all"
}')
echo -e "Run discovery for mon-client-2.company.toplevel with fix_all.\n"
I don’t know if I miss something (I guess I do), but I just spent time to get this running and couldn’t make it work.