Used Add Host SNMP, but discover services add nothing

I used the following to add a SNMP host:
curl -k “https://mycmkhost/cmk/check_mk/webapi.py?_username=automation&_secret=${secret}&action=add_host
-d
‘request={“folder”:“SNMP”,“hostname”:"’"${1}"’",“attributes”:{“ipaddress”:"’"${2}"’",“tag_agent”:“no-agent”,“tag_snmp_ds”:“snmp-v2”,“snmp_community”:[“authNoPriv”, “sha”, “YYYY”, “XXXX”]}}’
I then activate_changes, then discover_services with ‘request={“hostname”:"’"${1}"’",“mode”:“fixall”}’
But does not find anything and then the green Fix All still shows.
How to do I fix this via WEB-API command?

The above command is followed by:
curl -k “https://mycmkhost/cmk/check_mk/webapi.py?_secret=${secret}&_username=automation&action=activate_changes
-d ‘request={“sites”:[“cmk”],“allow_foreign_changes”:“1”}’
Which returns something simular to:
{“result_code”: 0, “result”: {“sites”: {“cmk”: {"_site_id": “cmk”, “_phase”: “done”, “_state”: “success”, “_status_text”: “Success”, “_status_details”: “Started at: 21:12:01. Finished at: 21:12:05.”, “_time_started”: 1637010721.2938225, “_time_updated”: 1637010725.6666067, “_time_ended”: 1637010725.6666067, “_expected_duration”: 5.736698716754278, “_pid”: 2800}}}}

Then I issue:
curl -k “https://mycmkhost/cmk/check_mk/webapi.py?_username=automation&_secret=${secret}&action=discover_services
-d
‘request={“hostname”:"’"${1}"’",“mode”:“fixall”}’
With argument ${1} being passed in as hostname of server that was added.

I get:
{“result_code”: 0, “result”: “Service discovery successful. Added 0, removed 0, kept 0, total 0 services and 0 new, 0 total host labels”}

And the green “Fix All”, still needs to be acted upon within the GUI.

I think this is a API bug a already saw some days ago. You cannot move services from the discovery state undecided to monitored or ignored with an API call.

In my test i was using the “update_discovery_phase” call, but it is possible that you have the same problem with your “discover_services”.

Yes I have tried both WEB and REST API and get the same results.
Can you tell me the bug #?

Inside the web interface (Setup menu) it is working without any problem. That what i saw was only the API call.

Yes I agree. That if you use the GUI all works as expected. We want non-admins via scripts to add devices. BTW: This only affects SNMP.

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.