API endpoint to check bandwidth usage

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
spilafis
Posts: 4
Joined: Wed May 29, 2019 9:33 am

API endpoint to check bandwidth usage

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API endpoint to check bandwidth usage

Post by scottwilkerson »

You would need to get it from the following API
Help -> Objects Reference -> objects/rrdexport
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
spilafis
Posts: 4
Joined: Wed May 29, 2019 9:33 am

Re: API endpoint to check bandwidth usage

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API endpoint to check bandwidth usage

Post 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)
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
spilafis
Posts: 4
Joined: Wed May 29, 2019 9:33 am

Re: API endpoint to check bandwidth usage

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API endpoint to check bandwidth usage

Post by scottwilkerson »

No, 1559501700 is Sunday, June 2, 2019 6:55:00 PM GMT
1 day ago
https://www.epochconverter.com/
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
spilafis
Posts: 4
Joined: Wed May 29, 2019 9:33 am

Re: API endpoint to check bandwidth usage

Post by spilafis »

Nice! thank you very much scottwilkerson !!!
I think this is what I needed then.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API endpoint to check bandwidth usage

Post by scottwilkerson »

spilafis wrote:Nice! thank you very much scottwilkerson !!!
I think this is what I needed then.
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked