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?
Trigger downtime via Jenkins
Re: Trigger downtime via Jenkins
You can schedule downtime in Nagios XI from the CLI via the REST API. Here's an example command:
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.
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"You can view the REST API documentation under the "Help" menu in Nagios XI web UI.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Trigger downtime via Jenkins
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:
But how can i change the time and date? the value 1556822794 is something, but what exactly?
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>-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Trigger downtime via Jenkins
It is a unix timestamp in seconds
This would give you the current date
This would give you the current date
Code: Select all
echo $(date +%s)