Getting graphs using API from a Juniper device

I really would like to pull graphs from LibreNMS using Python. But I’m stuck on the command line. (Sorry - https has been removed from examples to circumvent the restriction of having too many links in my text)

A general request for my device works fine:
curl -H ‘X-Auth-Token: de1a4512’ ‘//librenms/api/v0/devices/lgb-pr1.core.fsknet.dk/ports/’
{
“status”: “ok”,
“ports”: [
{
“ifName”: “fxp0”
},

{
“ifName”: “xe-0\/1\/0”
},
{
“ifName”: “xe-0\/1\/1”
},

],
“count”: 108
}

But when asking for a specific port, things go all wrong:

curl -H ‘X-Auth-Token: de1a4512’ ‘//librenms/api/v0/devices/lgb-pr1.core.fsknet.dk/ports/xe-0\/1\/0/port_bits?from=-1w&to=-300’
{
“status”: “error”,
“message”: “Invalid graph type”
}

I can’t see how to avoid the \/ as the interface-descriptions written says so. Trying

curl -H ‘X-Auth-Token: de1a4512’ ‘//librenms/api/v0/devices/lgb-pr1.core.fsknet.dk/ports/xe-0_1_0/port_bits’

gives no output. And

curl -H ‘X-Auth-Token: de1a4512’ ‘//librenms/api/v0/devices/lgb-pr1.core.fsknet.dk/ports/xe-0_1_0/port_bits?from=-1w&to=-300’


<xhtml:div style=“display:table; width:300px; height:100px; overflow:hidden;”>
<xhtml:div style=“display:table-cell; vertical-align:middle;”>
<xhtml:div style=“color:rgb(128, 0, 0); text-align:center; font-family:sans-serif; font-size:0.6em;”>Error Drawing Graph: ERROR: start (1683653227) should be less than end (1683642127)</xhtml:div>
</xhtml:div>
</xhtml:div>

Any suggestions on what to do?

BTW - LibreNMS itself is perfectly happy with the interface:
image

Thanks - Jan Ferré

I’m not near a test machine, but I think you have to URI encode it, some random bash example I have laying around does it like this for example:

~$ echo 'xe-0/1/0' | sed -e 's/\//%2f/g'
xe-0%2f1%2f0

./routes/api.php: Route::get('{hostname}/ports/{ifname}', 'LegacyApiController@get_port_stats_by_port_hostname')->name('get_port_stats_by_port_hostname')->where('ifname', '.*');

I would suggest URL encode your port name ( as above ) and use to and from as epoch seconds

here is an example sysadmin_scripts/create_public_graphs.sh at master · pozar/sysadmin_scripts · GitHub

Although the documentation says you can also use time styles as per RRDtool - rrdgraph but I would start with epoch times and then try other formats if that makes things easier …

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.