Page 1 of 1

PowerShell script schedule downtime

Posted: Fri Jun 07, 2019 2:50 pm
by jkinning
I am trying to figure out the correct way to use a PowerShell script to run on a Windows server so it schedules downtime using the Nagios API. I am looking to add this to a pre-patch process so it runs, the host schedules downtime for 1 or 2 hours (still undecided) then returns to normal monitoring mode after the schedule expires.

Anyone doing something similar that they could provide me some examples? I am still wet behind the ears with PowerShell but trying to do more and more with it.

Re: PowerShell script schedule downtime

Posted: Fri Jun 07, 2019 4:23 pm
by ssax
This is in the Nagios Core section, as Nagios Core doesn't have an API did you mean for this to be in the XI section?

Re: PowerShell script schedule downtime

Posted: Mon Jun 10, 2019 6:01 am
by jkinning
Yes, I was jumping around the various boards looking for a solution.

Are you able to move this thread?

Re: PowerShell script schedule downtime

Posted: Mon Jun 10, 2019 9:03 am
by ssax
Yes, I just moved it to the Customer XI section.

So for a powershell script you're just going to be doing a web post using the downtime API URL:

Code: Select all

http://YOURXISERVER/nagiosxi/help/api-system-reference.php#system-schedule-downtime
I did find this google'ing, that should give you a really good generic example:

Code: Select all

https://www.powershellgallery.com/packages/MrANagios/1.2/Content/Invoke-NagiosXiApi.ps1
What specific questions do you have about it?