Page 1 of 1

Historical data with numeric measurement from REST API

Posted: Thu Aug 24, 2017 3:36 pm
by nagmoto
I've been trying to get Nagios historical (Archive JSON CGI) data using its REST API (jsonquery.html). I figured out that I can only get a flag "OK" or "NOK" for CPU Load for example, when querying it for past data, unlike when getting status data (Status JSON CGI) where I don't get "OK" or "NOK", but I get the actual numeric values, for example, CPU load numerically (ex: CPU_Load=x.xxx; y.yyy; z.zzz).

In one of the attachments here (Example of data for chart of historical data) we have a chart that shows data from the past about CPU Load. Since I can generate this chart with numeric values, I believe Nagios keeps these values but the REST API for historical data does not expose numbers themselves to the end user.
Attachment 1
Attachment 1
The second attachament (Example of statusJSON.cgi with numeric values) shows numeric values which is just what I need, but this represents current data/status. My question is how can I have access to numeric values from the past?? Is it possible to quer statusJSON.cgi setting start and end time so I can get, let's say, a collection of CPU load values from timestamp1 to timestamp2? For example: https://myserver/nagios/cgi-bin/statusj ... 1496274384
Attachment 2
Attachment 2

Thanks!

Re: Historical data with numeric measurement from REST API

Posted: Thu Aug 24, 2017 3:44 pm
by scottwilkerson
The graph you are displaying is created from the RRD file from pnp4nagios. And you can extract them with rrdtool

Re: Historical data with numeric measurement from REST API

Posted: Thu Aug 24, 2017 4:00 pm
by nagmoto
Can I retrieve same metric data from statusjson.cgi, instead of rrdtool ?

Re: Historical data with numeric measurement from REST API

Posted: Thu Aug 24, 2017 4:13 pm
by scottwilkerson
nagmoto wrote:Can I retrieve same metric data from statusjson.cgi, instead of rrdtool ?
No this is not possible.

You can retrieve a single line as you noticed in the perf_data field. That is the info, but just for the latest check.

Re: Historical data with numeric measurement from REST API

Posted: Sat Aug 26, 2017 9:04 am
by nagmoto
Thanks, please close this thread.