Hello,
I am trying to use the Backend API to extract Nagios data and I noticed that the getstatehistory command only returns recent historical data by default.
http://<nagios_server>/nagiosxi/backend/?cmd=getstatehistory&username=nagiosadmin&ticket=<my_ticket>
How would I specify a target time interval for getstatehistory? Also, is there some more detailed documentation available on Backend API, I was only able to find brief docs on how to get started.
Regards,
Ciprian
Bakend API getstatehistory time interval
Re: Bakend API getstatehistory time interval
To get an idea of the GET params available, open the state history report in a new tab. Now choose some option from the dropdowns and click "update". The address bar url should now contain all the necessary params for the query. For example, a report for the last 24hours resembles:
And a report for a custom timeframe resembles:
Does this help?
Code: Select all
http://<ip>0/nagiosxi/reports/statehistory.php?host=&service=&search=&reportperiod=last24hours&startdate=&enddate=&host=<hostname>&hostgroup=&servicegroup=&statetype=hard&reporttimesubmitbutton=Update&manual_run=1&page=1&records=25Code: Select all
http://<ip>/nagiosxi/reports/statehistory.php?host=<hostname>&service=&search=&reportperiod=custom&startdate=2014-10-04&enddate=2014-11-05&host=192.168.4.39+yerp&hostgroup=&servicegroup=&statetype=hard&reporttimesubmitbutton=Update&manual_run=1&page=1&records=25Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Bakend API getstatehistory time interval
Much appreciate the quick response.
I still can't the get backend API to return records the way statehistory.php displays them.
With this URL I can see a number of records from statehistory.php:
http://<nagios_server>/nagiosxi/reports/statehistory.php?host=&service=&search=&reportperiod=custom&startdate=2014-10-17&enddate=2014-11-11
Using the same startdate and endate parameters with getstatehistory backend API I get 0 records:
http://<nagios_server>/nagiosxi/backend/?cmd=getstatehistory&username=nagiosadmin&ticket=<my_ticket>&startdate=2014-08-17&enddate=2014-11-11
It seems startdate and endate parameters don't apply to getsatehistory backend API the same way as in statehistory.php. Any thoughts?
Thanks,
Ciprian
I still can't the get backend API to return records the way statehistory.php displays them.
With this URL I can see a number of records from statehistory.php:
http://<nagios_server>/nagiosxi/reports/statehistory.php?host=&service=&search=&reportperiod=custom&startdate=2014-10-17&enddate=2014-11-11
Using the same startdate and endate parameters with getstatehistory backend API I get 0 records:
http://<nagios_server>/nagiosxi/backend/?cmd=getstatehistory&username=nagiosadmin&ticket=<my_ticket>&startdate=2014-08-17&enddate=2014-11-11
It seems startdate and endate parameters don't apply to getsatehistory backend API the same way as in statehistory.php. Any thoughts?
Thanks,
Ciprian
Re: Bakend API getstatehistory time interval
My apologies, I forgot the backend is slightly different. It uses unixtime and the params "starttime" and "endtime". For example:
Code: Select all
http://<ip>/nagiosxi/backend/?cmd=getstatehistory&starttime=1415311302&endtime=1415312302Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Bakend API getstatehistory time interval
That worked. Thanks!