API example code to get graphs

I am one of the co-founders of a peering fabric (Internet eXchange) in the San Francisco CA area. We wanted a way to pull daily and weekly graphs out of LibreNMS to display on our web site. I first ran rrdtool to create this on the LibreNMS box and then transferred these to the web site but found that a bit cumbersome. In drilling into the LibreNMS, I found I could get nearly everything I wanted via the API. Of course some of this is not documented so I had to dig through the code to find what I wanted.

One thing that was handy here was leveraging Libre’s concept of groups here to use this to identify ports I wanted to aggregate up. These are identified as “peering” in this script.

Additionally there doesn’t seem to be a way to add a title to a graph but I resolved that by using Imagemagick’s “convert” on the image I got via the API.

You can see the script at:

1 Like

I’m not sure if their’s a question in here or not :slight_smile:

However this API call gets your peering graphs: http://docs.librenms.org/API/API-Docs/#api-route-get_graph_by_portgroup

1 Like

No question. Just a post and pointer to a solution that we found for SFMIX. The code pointed to also shows some API arguments that are not (well) documented but are in the LibreNMS code that we found useful.

Your link is broken, I get a 404.

If you can improve the docs then please submit pull requests :slight_smile:

My apologies. That repro was private. It is now public.

Heh… Back in the FidoNet days. it was “Send code”. Will do.

This is an open source project and relies on people contributing to make it work :slight_smile: