Correct usage of 'starttime' to query objects/statehistory?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
amoss24
Posts: 31
Joined: Thu Dec 17, 2020 1:19 pm

Correct usage of 'starttime' to query objects/statehistory?

Post by amoss24 »

Hi all,

Trying to look at the API in order to have a better idea of how ServiceNow's Event Management module is collecting data from Nagios.

In querying the objects/statehistory endpoint, what is the correct use of 'starttime'?

I have an example based on what arguments ServiceNow uses, and I am adding in pretty=1 so I can read the output when I try to query the API:

Code: Select all

https://nagiosxi.domain.com/nagiosxi/api/v1/objects/statehistory?starttime=1620331491&orderby=state_time:d&pretty=1&records=3000&apikey=MyAPIKeyHere
By setting my start time to 1620331491, I am under the belief that I would expect results from Thu May 06 2021 20:04:51 GMT and newer. However, I am confused because I am seeing results that go further back than expected, here's the oldest result from the request above:

Code: Select all

 "state_time": "2021-05-06 15:06:36"
Just looking for clarification, or if something with our Nagios installation is not correct.

Thank you in advance!
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Correct usage of 'starttime' to query objects/statehisto

Post by gsmith »

Hi,

The starttime is GMT. Is your Nagios XI server's timezone set for America/Chicago?

Thanks
amoss24
Posts: 31
Joined: Thu Dec 17, 2020 1:19 pm

Re: Correct usage of 'starttime' to query objects/statehisto

Post by amoss24 »

Hi @gsmith,

It is interesting you bring that up. Our team recently standardized on UTC (GMT) time since we span multiple time zones, and the server was changed. This means I can run 'date' and output the expected results: Fri May 7 15:21:36 UTC 2021

However, I checked our system profile and can see this:
Date/Time
PHP Timezone: America/Chicago
PHP Time: Fri, 07 May 2021 10:24:08 -0500
System Time: Fri, 07 May 2021 15:24:08 +0000
Should the PHP timezone match the system time? That would make sense if that is causing our issues. I hadn't even thought to check that.

To add to this,

I just checked and I do indeed see that we did not change the timezone in the XI interface. If the system time and the time in XI need to match I will change.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Correct usage of 'starttime' to query objects/statehisto

Post by gsmith »

Hi,

Yes, matching the XI timezone with the server's timezone is the recommended practice.

Once you make the change please let me know if things are working as expected.

Thanks
amoss24
Posts: 31
Joined: Thu Dec 17, 2020 1:19 pm

Re: Correct usage of 'starttime' to query objects/statehisto

Post by amoss24 »

That indeed fixed the issues I was encountering. I think we mistakenly updated the system time from the terminal when the documentation states that we should just update it from the XI interface.

Thank you @gsmith
Locked