Trigger downtime via Jenkins

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
wagnbeu0
Posts: 27
Joined: Tue Nov 03, 2015 5:28 am

Trigger downtime via Jenkins

Post 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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Trigger downtime via Jenkins

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
wagnbeu0
Posts: 27
Joined: Tue Nov 03, 2015 5:28 am

Re: Trigger downtime via Jenkins

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Trigger downtime via Jenkins

Post by scottwilkerson »

It is a unix timestamp in seconds

This would give you the current date

Code: Select all

echo $(date +%s)
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked