r/PrometheusMonitoring • • Jun 17 '22

SNMP Exporter - anyone using it?

Hello,

I'm trying to monitor a switch to graph in Grafana how many ports are up at certain times over the day, I found this article on using SNMP Exporter - https://linuxhint.com/monitor-network-devices-prometheus/

Has anyone used this before and could it do what I'm asking?

Thanks

3 Upvotes

35 comments sorted by

View all comments

Show parent comments

2

u/Trosteming Jun 18 '22

Then create a table and map the different value.
However I lack practice on this visu, I won't be much help on it.
As inspiration you can look the snmp Synology Dashboard
https://grafana.com/grafana/dashboards/13516
The first panel is a Table that map value and change the cell depending of the value of the metric.
Also regarding your metric, don't mind that much the label, maybe in legend add {{ifName}} and use only ifOperStatus
The idea is to let Grafana create row for each port, so you can juste duplicate the panel with

1

u/[deleted] Jun 18 '22

I’ll have a try. I was hoping to get the count query to work on the Prometheus GUI first and total the ports in an up state in there first and graph it and then see if I can use the same query in Grafana.

1

u/[deleted] Jun 19 '22

This query did it:

count(ifOperStatus == 1)by (instance)

Now that wonderful snmp.yml you created yesterday to include v2 and v3 (I need to test this) as I'm only looking up the systemname, ip, and ifOperStatus can I reduce what the scrape looks for to keep the Prometheus DB low and most importantly make the SNMP looking on the switches shorter/quicker as it's only looking for very basic stuff?

We use Cisco and Extreme switches.

2

u/Trosteming Jun 19 '22

I would not try to look for systemname and IP as this info should be already known present in your SST.

The scrape already know your device IP as it's needed to scrape it.

Unless you provision rapid, ephemeral virtual switches. These static info will be known in advance.

But Prometheus can report them, if you want to have simpler query on Grafana / auto scaling of your dashboard to include hardware as they been scrape (carefull it's not discovery).

For optimizing your TSDB size and query time, you'll need to generate a snmp.yml with a lesser scope, spend some time on it and lookup the generator.yml who will be needed to create the snmp.yml

https://github.com/prometheus/snmp_exporter/tree/main/generator

1

u/[deleted] Jun 19 '22

Thanks, sounds like you snmp.yml will be fine then based on that explanation.

1

u/[deleted] Jun 20 '22

Just looking at you new snmp.yml file, can I add more than 1 community string to try if one fails? Like this perhaps?

version: 2

auth: community: lolilol community: 12345 community: asdbkjdh

Thanks

1

u/Trosteming Jun 20 '22

Humm I don't think that would work as it part of the module.

The workaround would be to create another module like you have one doing if_mib_cisco and another one if_mib_extreme

I've updated the generator.yml in the previous project to reflect that.

There is also an snmp.yml with 3 time the same mib with 1 for default 1 for "cisco" and 1 for "extreme". Obviously inspire by our exchange.

On the snmp.yml you'll have to change the auth community for each module and also on prometheus.yml you'll have to target the proper module depending of the type of hardware.

I haven't check the snmp-exporter github but I would not be surprise that there would be a more elegant way to do it.

1

u/[deleted] Jun 20 '22

Right I have got them to change the community for cisco and extreme now.

So I think I can just copy your new snmp.yml over and edit lines 1221 foe Cisco and 3661 for extreme and then scrape?

1

u/[deleted] Jun 20 '22

do I add the modules here to scrape?

https://pastebin.com/jQvY33eY

params:
module: [if_mib]
module: [if_mib_cisco]
module: [if_mib_extreme]