0

I am trying to automate the setting and removal of downtimes on icinga hosts.

I am currently using the following command:

(note that I'm running this in an ansible playbook so {{item}} is the hostname and any other double brackets are filled in with ansible variables)

curl -k -s -u {{username}}:{{password}} -H 'Accept: application/json' -X POST "https://localhost:5665/v1/actions/schedule-downtime?filter=host.name==%22{{item}}%22&type=Host" -d "{ \"start_time\": \"{{now}}\", \"end_time\": \"{{end}}\", \"duration\": 1000, \"author\": \"{{username}}\", \"comment\": \"auto set downtime on {{item}}\" }"

This is able to put the host into a downtime. However, it doesn't put any services on that host into that downtime. This is as if I went into the web ui and put the host into a downtime without selecting the "all services" checkbox.

How can I change this command to put the host into a downtime, while also putting all services on that host into a downtime?

I would also be interested if there was an ansible task that could also preform this function.

Alex Cohen
  • 5,596
  • 16
  • 54
  • 104

1 Answers1

1

The answer is to change the &type=Host bit at the end of the url to &type=Service to do service downtimes instead of host downtimes.

curl -k -s -u {{username}}:{{password}} -H 'Accept: application/json' -X POST "https://localhost:5665/v1/actions/schedule-downtime?filter=host.name==%22{{item}}%22&type=Service" -d "{ \"start_time\": \"{{now}}\", \"end_time\": \"{{end}}\", \"duration\": 1000, \"author\": \"{{username}}\", \"comment\": \"auto set downtime on {{item}}\" }"
Alex Cohen
  • 5,596
  • 16
  • 54
  • 104