Hi,
I want to get a message 30 minutes before a downtime ends.
Is it possible to get the downtime end with an API call?
Hi,
I want to get a message 30 minutes before a downtime ends.
Is it possible to get the downtime end with an API call?
Hi @derSven
you can query v1/objects/downtimes
for this.
curl -k -s -u user:password 'https://<servername>:5665/v1/objects/downtimes' -X POST -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -d '{"attrs" : ["end_time"]}'
Kind regards
Hey,
i’ve got the same question. After queries the API with the curl, i always become this return message:
{“error”:404.0,“status”:“No objects found.”}
If I query my hosts with the filter “host.downtime_depth != 0”, I’ll retrieve the hosts as expected.
The /downtimes object is still not well documentated as I see.
Any Ideas?
Hey @Toby
does your API user have the correct permissions?
permissions = [ "objects/query/Downtime" ]
Kind regards
Hey @ritzgu
I added the permission, but that does not solve the Problem.
The response is still “no objects found” but in the web ui are active downtimes
Kind regards
Hey
What version of icinga2 are you using? (I’m on r2.12.3-1)
The following works just fine for me:
ApiUser config:
object ApiUser "test" {
password = "***************"
permissions = [ "objects/query/Downtime" ]
}
curl:
curl -k -s -u test:*************** 'https://localhost:5665/v1/objects/downtimes?pretty=1' -X POST -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -d '{"attrs" : ["end_
time"]}'
result:
{
"results": [
{
"attrs": {
"end_time": 1622363375.0
},
"joins": {},
"meta": {},
"name": "hostname!servicename!<GUID>",
"type": "Downtime"
}
]
}
Hey @ritzgu
I am on r2.8.2.
Hey @ritzgu,
I tried it again and got the expected response.
Nice! Keep in mind that r2.8.2 is already three years old!