Page 1 of 1
API endpoint to check bandwidth usage
Posted: Thu May 30, 2019 9:49 am
by spilafis
Hi,
I trying to find if there is any endpoint in the Nagios XI rest API (or any other backend endpoint I could query) to get the bandwidth usage information for a host.
I know there is bandwidth usage information available on the system because I see it on the reports, but I can't find where to get that information through the API so that we can integrate this information from Nagios into other systems.
Thanks in advance for any information you may provide.
Re: API endpoint to check bandwidth usage
Posted: Thu May 30, 2019 10:20 am
by scottwilkerson
You would need to get it from the following API
Help -> Objects Reference -> objects/rrdexport
Re: API endpoint to check bandwidth usage
Posted: Mon Jun 03, 2019 1:54 pm
by spilafis
Thanks for the reply @scottwilkerson
Unfortunately querying that endpoint through the API the response I get doesn't seem to much the information that is displayed on the Bandwidth Usage report.
The strange thing is that the data returned seems to be old.
So, for example, when I query it for just a host name and a service description I get this response:
Code: Select all
{
"meta": {
"start": "1559501700",
"step": "300",
"end": "1559501700",
"rows": "289",
"columns": "2",
"legend": {
"entry": [
"in",
"out"
]
}
},
"data": {
"row": [
{
"t": "1559501700",
"v": [
"0.0000000000e+00",
"0.0000000000e+00"
]
},
...
Which doesn't make sense if the start is in seconds.
I contacted Nagios Support and they told me that I should look for a file in var/lib/mrtg/mrtg which should be the source used for the report. Because the Bandwidth Usage uses a different database.
If anyone may elaborate on this in case some has already done this, please do here.
Re: API endpoint to check bandwidth usage
Posted: Mon Jun 03, 2019 2:07 pm
by scottwilkerson
Each of these is a value for the timestamp
Code: Select all
"row": [
{
"t": "1559501700",
"v": [
"0.0000000000e+00",
"0.0000000000e+00"
]
},
the first in the "v" is
in and the 2nd is the
out
Based on the query you ran, you should have one value for every 300 seconds (step)
Re: API endpoint to check bandwidth usage
Posted: Mon Jun 03, 2019 2:14 pm
by spilafis
Right, that's what I thought too.
But if you see the timestamp is 1559501700
Which would be very old if it is seconds.. since it would be from 18 days ago?
Why is it not showing yesterday's data, for example, if I see yesterday's data in the report for same host and service?
Re: API endpoint to check bandwidth usage
Posted: Mon Jun 03, 2019 2:30 pm
by scottwilkerson
No,
1559501700 is Sunday, June 2, 2019 6:55:00 PM GMT
1 day ago
https://www.epochconverter.com/
Re: API endpoint to check bandwidth usage
Posted: Mon Jun 03, 2019 2:33 pm
by spilafis
Nice! thank you very much scottwilkerson !!!
I think this is what I needed then.
Re: API endpoint to check bandwidth usage
Posted: Mon Jun 03, 2019 2:43 pm
by scottwilkerson
spilafis wrote:Nice! thank you very much scottwilkerson !!!
I think this is what I needed then.
Great!
Locking thread