Page 1 of 1

Need help on host/service removal from maintenance mode

Posted: Mon May 20, 2019 10:36 am
by bsivavani
Hi,

I am able to place the host/service in scheduled downtime using below command

curl --silent --show-error --data cmd_typ=86 --data cmd_mod=2 --data host="XXXXX" --data com_data="Placing server in scheduled downtime from command line" --data trigger=0 --data start_time="05-20-2019 17:20:00" --data end_time="05-20-2019 17:30:00" --data fixed=1 --data hours=2 --data minutes=0 --data btnSubmit=Commit --insecure https://localhost/nagios/cgi-bin/cmd.cgi -u username:passwd

Can you advice how to delete/cancel the services from maintenance mode ?

Re: Need help on host/service removal from maintenance mode

Posted: Mon May 20, 2019 4:23 pm
by npolovenko
@bsivavani, You can schedule/delete downtime using the API. I think you need to upgrade to XI 5.6.2 to get access to these commands.
1. Get the ID number of a particular downtime you want to delete.
Untitled2.png
2. Delete downtime using ID number via API command:
Untitled.png

Re: Need help on host/service removal from maintenance mode

Posted: Mon May 20, 2019 4:29 pm
by scottwilkerson
You would need to know the scheduled downtime ID, The only way I know how to get this is the following:

Code: Select all

http://YOURHOST/nagiosxi/includes/components/nagioscore/ui/statusjson.php?query=downtimelist&hostname=XXXXX&apikey=XXXXXXXXX
What you are looking for is the value on the downtimelist

Then in XI from
Help -> API Docs -> System Reference
follow the DELETE system/scheduleddowntime/<internal_id>

replacing <internal_id> with the ID you extracted above

Re: Need help on host/service removal from maintenance mode

Posted: Tue May 21, 2019 8:43 am
by bsivavani
I tried with below command to cancel the scheduled downtime, but not able to remove/cancel maintenance mode.

curl --silent --show-error --data cmd_typ=86 --data cmd_mod=2 --data down_id=2 --data host="remotehost" --data com_data="Placing server in scheduled downtime from command line" --data trigger=0 --data fixed=1 --data childoptions=0 --data btnSubmit=Commit --insecure https://localhost/nagios/cgi-bin/cmd.cgi -u username:password

Re: Need help on host/service removal from maintenance mode

Posted: Tue May 21, 2019 2:27 pm
by scottwilkerson
This isn't going to work.

First cmd_typ=86 is for creating downtime not removing it

Second, where did you get the ID (2) you are using as the down_id ?

If it was going to work this way at all it would be with the following, replacing XXXX with the actual downtime ID

Code: Select all

curl --silent --show-error --data cmd_typ=78 --data cmd_mod=2 --data down_id=XXXX --data btnSubmit=Commit --insecure https://localhost/nagios/cgi-bin/cmd.cgi -u username:password

Re: Need help on host/service removal from maintenance mode

Posted: Tue Jun 04, 2019 5:22 am
by bsivavani
Thanks for the update. Please close the request.

Re: Need help on host/service removal from maintenance mode

Posted: Tue Jun 04, 2019 6:48 am
by scottwilkerson
bsivavani wrote:Thanks for the update. Please close the request.
Great

Locking