API step is not correct

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
rragha2
Posts: 17
Joined: Mon Aug 03, 2020 4:57 am

API step is not correct

Post 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"
]
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: API step is not correct

Post 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?
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
rragha2
Posts: 17
Joined: Mon Aug 03, 2020 4:57 am

Re: API step is not correct

Post 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"
]
},
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: API step is not correct

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
rragha2
Posts: 17
Joined: Mon Aug 03, 2020 4:57 am

Re: API step is not correct

Post by rragha2 »

Please find the Profile System in your PM.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: API step is not correct

Post 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?
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
rragha2
Posts: 17
Joined: Mon Aug 03, 2020 4:57 am

Re: API step is not correct

Post by rragha2 »

The data was achieved by putting http://10.X.X.X/nagiosxi/ in URL of web browser.
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API step is not correct

Post 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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API step is not correct

Post 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
rragha2
Posts: 17
Joined: Mon Aug 03, 2020 4:57 am

Re: API step is not correct

Post by rragha2 »

Thanks for you information.

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