Unfortunately, there is little to no documentation for using the Icinga Web API to perform monitoring actions such as scheduling downtimes. But it’s a simple thing and I’ll give you a quick example of how to do it. Using the Icinga Web API instead of the Icinga API gives you the advantages of the permission and restriction system, various authentication methods and auditing.
Icinga Web supports API access to all forms by simply adding the
Accept: application/json header to the requests. In the following examples we plan downtimes for single and multiple hosts and services. The required fields for planning downtimes are the following:
typewhich is either
startas UNIX timestamp
endas UNIX timestamp
The following command creates a downtime for
$hostname for the next hour.
curl -H "Accept: application/json" -u user:password \ "https://$server/icingaweb2/monitoring/host/schedule-downtime?host=$hostname" \ -F "type=fixed" \ -F "start=$(date +%s)" \ -F "end=$(expr $(date +%s) + 3600)" \ -F "comment=Reboot"
If you want to create downtimes for all services on this host as well, just add
If you want to plan downtimes for multiple hosts, the URL looks like this:
$filter can be used from the multi-select or list views, e.g.
Scheduling service downtimes is done using the following URLs:
If you want to use the API for other monitoring commands, use your browser’s developer tools to see which URL is used by the relevant forms and what data they POST.
You can also find more how-tos at community.icinga.com.