Page 1 of 1
Nagios Scripting
Posted: Mon Jan 05, 2026 1:43 pm
by rickcote13
Is there a single API that mimic the online transaction of Blackout all services ?
I am trying to script a startup /shutdown script that puts it in blackout when it is shutdown and not crashed and taken out when it comes back up.
I have enabled host, but seems to continue with services.
Thanks
Re: Nagios Scripting
Posted: Thu Jan 08, 2026 12:45 pm
by 455157
I wonder if the
all_services paramater of the
POST system/scheduleddowntime endpoint is what you're after?
It states:
0 or 1 for all services on specified hosts
Re: Nagios Scripting
Posted: Thu Jan 08, 2026 9:18 pm
by fattyraft
There isn’t a single API call that behaves exactly like the web UI “blackout all services” action. Under the hood, Nagios handles this by scheduling downtime per object.
For what you’re trying to do, the usual approach is to use the external command interface and submit scheduled downtime for the host and its services on shutdown, then remove it on startup. Simply enabling host downtime won’t automatically suppress service alerts unless you explicitly schedule service downtime as well.
Take a look at SCHEDULE_HOST_DOWNTIME together with SCHEDULE_HOST_SVC_DOWNTIME (or loop over services) in your script. That should get you much closer to the behavior you see in the UI.
Re: Nagios Scripting
Posted: Fri Jan 09, 2026 11:03 am
by 455157
Testing showed that the
all_services parameter of the
system/scheduleddowntime REST API endpoint did what I expected (and, I believe, what OP is after?).
It placed all services on the target host in downtime as well. Running this (replacing the server IP, API key, hostname, timstamps, and comment with your own settings) will place both the host and all of it's services in downtime:
Code: Select all
curl -XPOST "<XI.machine.IP>/nagiosxi/api/v1/system/scheduleddowntime?apikey=<your.API.key>\
&pretty=1" -d "comment=Test downtime creation&start=1767974399&end=1767981599\
&hosts[]=localhost&all_services=1"