Get image of graph in librenms

Hi! excuse me, I need help and I hope you can help me. I want to take a screenshot or get the image of graph. But, it keeps stuck on login page. As we know, graphs in Librenms are in jpg like this:

I want to download it automatically by running python script.
this is the script:
import imgkit
import requests
import time
from requests.auth import HTTPBasicAuth
session = requests.session()
requests.get(‘http://192.168.0./login’, auth=HTTPBasicAuth('’, ‘***’)')
time.sleep(10)
imgkit.from_url(‘http://192.168.0.108/graphs/lazy_w=568/to=1564041300/device=2/type=device_bits/from=1563436500/legend=no/','libre.jpg’)

But, the output just like this (stuck on login page):

I want the output is the image that showing graph. Thank you.

The format is PNG (default) or SVG depending on your LibreNMS settings.

The example of embedding images in an HTML alert will help you work out how to make this in your python script:

https://docs.librenms.org/Alerting/Templates/

$config['allow_unauth_graphs_cidr'] = array('127.0.0.1/32');
$config['allow_unauth_graphs'] = true;

You need to test or wait until this pull request is merged into the code as currently a bug with unauth graphs https://github.com/librenms/librenms/pull/10483

you could possibly look at LibreNMS API as an alternate way for example " get_graph_by_portgroup" https://docs.librenms.org/API/PortGroups/ , not sure though if you can pull individual int graphs

2 Likes

I’ve added it. But, still can’t be accessed inside python

Can you browse directly to the image when logged out?

It can be browsed directly through browser, but it keeps failed when run python to get image screenshot

Hi @karinkf

Did you change 127.0.0.1/32 to the real range of device that will try to dowlnload the images ?

I’ve changed it, but it still didn’t work for python