What is the date format in the Nagios API?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
dev.mellano
Posts: 4
Joined: Wed Jan 18, 2017 6:52 am

What is the date format in the Nagios API?

Post by dev.mellano »

I am using Nagios API to get the critical servicelist, but I need to start date and end date for the the lastupdate field. what is the date format that I need to use it there? I tried the long one, but it seems it is not working.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: What is the date format in the Nagios API?

Post by rkennedy »

I believe you're referring to the unix timestamp - http://www.epochconverter.com/

If not, can you show us a screenshot where you're referring to?
Former Nagios Employee
dev.mellano
Posts: 4
Joined: Wed Jan 18, 2017 6:52 am

Re: What is the date format in the Nagios API?

Post by dev.mellano »

Suppose I need to get all the service list in critical status starting from 1/1/2017, I call the following API, am I right?
/nagios/cgi-bin/statusjson.cgi?query=servicelist&details=true&dateformat=l&servicestatus=critical&servicetimefield=lasttimecritical&starttime=1483228800
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: What is the date format in the Nagios API?

Post by tmcdonald »

This does not seem to give historical data, as the returned starttime parameter is always 1 on my machine, and no matter how far back I set the parameter it returns the same data. Going to check with our Core dev on this behavior.

To be clear, are you looking to limit the results to anything that was last updated between January 1 and now?

Update: If you are in fact looking for historical data, you will want to use something like:

nagios/cgi-bin/archivejson.cgi?query=alertlist&servicestates=critical&starttime=1473228800&endtime=1486411693
Former Nagios employee
Locked