Page 1 of 2

API step is not correct

Posted: Thu Jan 07, 2021 3:43 am
by rragha2
Hi,

We used the api with step=300 below to get data.
http://10.x.x.x/nagiosxi/api/v1/objects ... 5&step=300

Moderator's Note: Edited URL to remove sensitive data from the public forum.

However, we get the date with step=900
"meta": {
"start": "1609663500",
"step": "900",
"end": "1609663500",
"rows": "385",
"columns": "4",
"legend": {
"entry": [
"rta",
"pl",
"rtmax",
"rtmin"
]

Re: API step is not correct

Posted: Thu Jan 07, 2021 3:49 pm
by dchurch
I'm not certain what you're expecting as an output, and what's not coming through. Can you be more specific?

What do you expect when you specify step=300?
What do you expect when you specify step=900?
What comes out when you specify step=300?
What comes out when you specify step=900?

Re: API step is not correct

Posted: Thu Jan 07, 2021 8:23 pm
by rragha2
I put step=300 in API, so I am expecting the data should show at the right period(300).

http://10.X.X.X/nagiosxi/api/v1/objects ... b]step=300[/b]

{
"meta": {
"start": "1609810200",
"step": "900",
"end": "1609810200",
"rows": "289",
"columns": "4",
"legend": {
"entry": [
"rta",
"pl",
"rtmax",
"rtmin"
]
}
},
"data": {
"row": [
{
"t": "1609810200",
"v": [
"NaN",
"NaN",
"NaN",
"NaN"
]
},
{
"t": "1609811100",
"v": [
"3.6923777778e-02",
"0.0000000000e+00",
"8.3856000000e-02",
"2.3104888889e-02"
]
},
{
"t": "1609812000",
"v": [
"3.7209333333e-02",
"0.0000000000e+00",
"8.9685555556e-02",
"2.2895111111e-02"
]
},
{
"t": "1609812900",
"v": [
"4.2913777778e-02",
"0.0000000000e+00",
"9.4990666667e-02",
"2.8408888889e-02"
]
},

Re: API step is not correct

Posted: Fri Jan 08, 2021 2:13 pm
by dchurch
If you PM me a system profile I can diagnose further. Get one by going to Admin (top menu) => System Profile (in the left menu), then clicking the blue button.

If you're unable to generate the the profile through the web interface, please try generating it from the command line by running these commands as root:

Code: Select all

rm -rf /usr/local/nagiosxi/var/components/profile*
/usr/local/nagiosxi/scripts/components/getprofile.sh SUPPORT
Then send me the resulting /usr/local/nagiosxi/var/components/profile.zip file.
If the profile script fails, please include the ENTIRE output.

Re: API step is not correct

Posted: Sun Jan 10, 2021 8:11 pm
by rragha2
Please find the Profile System in your PM.

Re: API step is not correct

Posted: Mon Jan 11, 2021 5:21 pm
by dchurch
I'm not seeing the request to /rrdexport in your Apache access logs so I can't tell either way if it's being sent correctly.

How are you executing this API call? Is it a shell script that invokes a curl(1) call? A PHP script? Something else?

Re: API step is not correct

Posted: Mon Jan 11, 2021 9:40 pm
by rragha2
The data was achieved by putting http://10.X.X.X/nagiosxi/ in URL of web browser.

Re: API step is not correct

Posted: Tue Jan 12, 2021 4:37 pm
by ssax
I'm able to replicate this, sometimes...

When I pass 300, it shows 300, when I pass 600 it's showing 1800. I will post an update shortly, investigating now.

Re: API step is not correct

Posted: Tue Jan 12, 2021 5:18 pm
by ssax
This is automatically done by the backend rrdtool xport command, for example (this is what the command executes):

Code: Select all

rrdtool xport --start '1609809650' --step '300' DEF:0=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:1:AVERAGE XPORT:0:"" DEF:1=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:2:AVERAGE XPORT:1:"" DEF:2=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:3:AVERAGE XPORT:2:"" DEF:3=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:4:AVERAGE XPORT:3:"" |grep step
    <step>1800</step>
You can see the step automatically increased to 1800 regardless of what is entered/similar to what you see.

Based on the link below it's saying it's doing that because the maxrows is not high enough (default is 400):

https://lists.oetiker.ch/pipermail/rrd- ... 19368.html

It says you can pass in -m for max rows so I just increased to 9000 as a test and it worked:

Code: Select all

[root@xid ~]# rrdtool xport --start '1609809650' --step '300' -m 9000 DEF:0=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:1:AVERAGE XPORT:0:"" DEF:1=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:2:AVERAGE XPORT:1:"" DEF:2=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:3:AVERAGE XPORT:2:"" DEF:3=/usr/local/nagios/share/perfdata/localhost/_HOST_.rrd:4:AVERAGE XPORT:3:"" |grep step
    <step>300</step>
This one explains a bit more:

https://stackoverflow.com/a/34824890

I'll need to submit this to development so that they can add the ability to pass maxrows or automatically calculate based on the step and the amount of time.

EDIT: Submitted:

NEW TASK ID 15433 created - Nagios XI Bug Report: XI - rrdexprt API endpoint doesn't always honor step because maxrows is default of 400

Re: API step is not correct

Posted: Tue Jan 12, 2021 8:46 pm
by rragha2
Thanks for you information.

Please let us know once your development team finishes the task.