Nagios Scripting

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
rickcote13
Posts: 2
Joined: Mon Jun 30, 2025 8:23 am

Nagios Scripting

Post 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
455157
Posts: 50
Joined: Mon Sep 10, 2012 7:35 pm

Re: Nagios Scripting

Post 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
fattyraft
Posts: 1
Joined: Thu Jan 08, 2026 9:17 pm

Re: Nagios Scripting

Post 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.
455157
Posts: 50
Joined: Mon Sep 10, 2012 7:35 pm

Re: Nagios Scripting

Post 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"
Post Reply