Page 1 of 1
Trigger downtime via Jenkins
Posted: Thu May 02, 2019 5:46 am
by wagnbeu0
Hi, we use Nagios XI for monitorring services and hosts, and also Jenkins for CI.
whenever we patch our system we need manually trigger a downtimes for affected servers and their monitorred services.
Can we use jenkins to trigger downtimes for hosts and services automatically? Jenkins is able to run several commands.
If yes, what is the API or URL we can use to do so?
Re: Trigger downtime via Jenkins
Posted: Thu May 02, 2019 1:50 pm
by lmiltchev
You can schedule downtime in Nagios XI from the CLI via the REST API. Here's an example command:
Code: Select all
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/system/scheduleddowntime?apikey=xxx&pretty=1" -d "comment=Test downtime creation&start=1556822794&end=1556823394&hosts[]=localhost"
Using this command in Jenkins is out of scope of Nagios support.
You can view the REST API documentation under the "Help" menu in Nagios XI web UI.
Re: Trigger downtime via Jenkins
Posted: Wed May 29, 2019 6:43 am
by wagnbeu0
Hi, thanks for the help. I guess it is exactly what we need now.
After I have reconfigured my apache Webserver it is working now to get some infos.
BIt I have one understanding problem: How to generate the starttime and end time?
For example:
Code: Select all
E:\curl-7.65.0-win64-mingw\bin>curl --insecure -XPOST "https://nagiosserver.localdomain/nagiosxi/api/v1/system/scheduleddowntime?apikey=gggkvgumspvivkqtnii9974p8fafkal2n4mnhidebataro7hampgtq75ahhrq5qi&pretty=1" -d "comment=Test downtime creation&start=1556822794&end=1556823394&hosts[]=nagiosserver.localdomain"
{
"success": "Schedule downtime command(s) sent successfully.",
"scheduled": {
"hosts": [
"nagiosserver.localdomain"
]
}
}
E:\curl-7.65.0-win64-mingw\bin>
But how can i change the time and date? the value 1556822794 is something, but what exactly?
Re: Trigger downtime via Jenkins
Posted: Wed May 29, 2019 6:48 am
by scottwilkerson
It is a unix timestamp in seconds
This would give you the current date