Downtime for a single service of one host

Hi guys,

I’m new here and I hope you can help me with the following: I’m trying to set downtimes through the Icinga API. Now I checked the documentation here https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/
I can set two types of downtime SERVICE or HOST. This works fine so far. But now I want to set a downtime for just one service of a single host. I tried the following without success:

curl -k -s -u ‘actionuser’ -H ‘Accept: application/json’ -X POST ‘https://ICINGA-MASTER:5665/v1/actions/schedule-downtime?type=Service&filter=host.name==“HOST”&service.name=“SERVICE”’ -d ‘{ “author”: “ME”, “comment”: “TEST”, “notify”: true, “pretty”: true, “start_time”: 1550737892, “end_time”: 1550824292, “duration”: 60, “fixed”: false }’

This is not working. Where is my mistake?
Any help would be appreciated

Best
Steve

Hi,

What’s the returned message?

The second equal operator is missing another one, is that a copy paste issue, or really your sent command?

Cheers,
Michael

Hi @metme01454,

Maybe:
v1/actions/schedule-downtime?type=service&service='HOST'!'SERVICE'

I use it in a similar way inside a script for auto acknowledge a service:
v1/actions/acknowledge-problem?type=service&service='$DEVICEHOSTNAME'!'$SERVICE'

Regards.

Thanks a lot for your fast answer. Sorry, this was a copy and paste issue, I have a second equal operator there. The result is always the same, saying:
{
“results”: [

]

}
:frowning:

Ok. Instead of putting everything into the URL and use encoding there, I highly recommend to use a POST request with a body, and X-HTTP-Method-Override as header.

Something like this example:

curl -k -s -u root:icinga -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/actions/schedule-downtime' -d '{ "type": "Service", "filter": "host.name==\"HOST\" && service.name==\"SERVICE\"", "start_time": 1446388806, "end_time": 1446389806, "duration": 1000, "author": "icingaadmin", "comment": "IPv4 network maintenance", "pretty": true }'

I haven’t had the time to update the API docs to leave away the URL params yet. Maybe you can look into that after making things work :slight_smile:

Cheers,
Michael

I use:
curl -k -s -u root:icinga -H 'Accept: application/json' -X POST 'https://master:5665/v1/actions/schedule-downtime?type=service&service=HOST!SERVICE' -d '{ "author": "ME", "comment": "TEST", "notify": true, "pretty": true, "start_time": 1550737892, "end_time": 1550824292, "duration": 60, "fixed": false }'

And it works ok:

{
“results”: [
{
“code”: 200.0,
“legacy_id”: 1.0,
“name”: “HOST!SERVICE!5b7f82ec-1a1a-47ba-bd2b-5b2aceedd3b7”,
“status”: “Successfully scheduled downtime ‘HOST!SERVICE!5b7f82ec-1a1a-47ba-bd2b-5b2aceedd3b7’ for object ‘HOST!SERVICE’.”
}
]
}

Thanks a lot, this works for me too. But anyway I’ll also try the suggestion from Michael. Thanks for your help