I can use the below command to get a list of downtime ids for a specific host, but how do I get the downtime id for a specific service on a host?
curl -XGET 'http://xxxxxx:xxxxx@<nagios server>/nagios/cgi-bin/statusjson.cgi?query=downtimelist&formatoptions=whitespace&hostname=<hostname>&downtimeobjecttypes=service&downtimetimefield=starttime' -o down-id-list
Get Downtime ID For Specific Service
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Get Downtime ID For Specific Service
Hi,
One way to go about this is to use the REST API GET objects/downtime endpoint and just loop through to find the id for the service.
For example (change the ipaddress and apikey accordingly)
Let me know if that would work for you.
One way to go about this is to use the REST API GET objects/downtime endpoint and just loop through to find the id for the service.
For example (change the ipaddress and apikey accordingly)
Code: Select all
import requests
import json
ipaddress = '192.168.23.113'
apikey = 'sCWXTQ3rHtm483AgRUUtLi04v5ECCVmktCCGoU8mINpPPflWafJbRKeGO8fGjUh6'
data = requests.get("http://" + ipaddress + "/nagiosxi/api/v1/objects/downtime?apikey=" + apikey )
objects = json.loads(data.text)
def get_internal_downtime_id(hostname, service):
for item in objects['scheduleddowntime']:
if item['host_name'] == hostname and item['service_description']== service:
return item['internal_id']
print(get_internal_downtime_id('localhost', 'Current Load'))
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!