Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
1.99k stars 570 forks source link

API execute-command - No objects found #9707

Closed Virsacer closed 1 year ago

Virsacer commented 1 year ago

Describe the bug

Acording to documentation this should be the minimal command to execute an EventCommand on an endpoint:

curl -k -s -u root:xxxxxxxxx -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/actions/execute-command' -d '{"ttl":15,"endpoint":"host.fqdn","command":"my_event"}'

But the results is {"error":404,"status":"No objects found."}

When adding any existing hostname to the json like "host":"icinga2master",, the command is executed on the endpoint. And when just adding "type":"Host", it executes the command on the endpoint as many times as you have hosts.

To Reproduce

  1. Define an EventCommand
  2. Run the commands as above

Expected behavior

The command shoud run once without the need for undocumented parameter 'Type', 'Host' or 'Service'

Your Environment

julianbrost commented 1 year ago

Acording to documentation this should be the minimal command to execute an EventCommand on an endpoint:

How did you come to this conclusion? Your example omits filters like "type": "Service", "service": "agent!custom_service" in the example.

The command shoud run once without the need for undocumented parameter 'Type', 'Host' or 'Service'

Those are filters that apply to the whole API: https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#filters

Event commands run in the context of a checkable, so that checkable has to be specified.

Virsacer commented 1 year ago

I came to that conclusion, because there is no In addition to these parameters a filter must be provided below the table like on others.

But when filters are global this makes sense now... Sorry