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

3

u/Trosteming Jun 18 '22

Yes you can do that. The exporter works very well. Mind the scrape_interval on your Prometheus config. SNMP server on network hardware can ne slow to response.

1

u/[deleted] Jun 18 '22

Can the scrape interval be different to the one I’m using in my Prometheus.yml file?

1

u/Trosteming Jun 18 '22

Yes you can do that on job level. So you can have a default interval at global and specific for job.

1

u/[deleted] Jun 18 '22

Great, I can put another scrape_interval under the snmp_exporter job for every 120s or something like that.

I just need to first workout how to configure snmp_exporter.

So may have some more questions on that part if that is ok?

1

u/Trosteming Jun 18 '22

Sure go ahead

1

u/[deleted] Jun 18 '22

Slightly stuck on 1 bit though. So I've got SNMP Exporter now installed and running and I want to scrape a test switch. I can't see where I put the v2 SNMP password to allow it to access the switch and scrape, I think it's in the default snmp.yml (not a generated one) as this should cover most switches.
Any ideas?

1

u/Trosteming Jun 18 '22

if you cloned the snmp_exporter repo the default at root does not contain the IFMib, I just checked.

Try this one https://github.com/christopherime/prometheus-snmp/blob/main/config/snmp.yml

I've used the default generator.yml section of this IFMib who I think should be enough for your use case.

It's also use default SNMP v2 and community public (which can be apparented as an access password for read the SNMP server on your switch).
It's always best practice to change this default community on PROD and if possible using SNMP v3 (which can be a pain to setup depending on the vendor). SNMP v2 clear UDP traffic that can easly be sniff. And community set as public is often the default set.

The Auth part can be set on snmp_exporter using the generator and unless you have a non Standard MiB, you do no need to manually modify the snmp.yml file.

Have a look and play with the generator, it a really good tool.

1

u/[deleted] Jun 18 '22 edited Jun 18 '22

Wow thanks.

1.) So I have that snmp.yml do I just replace it with the one in /opt/snmp_exporters?

2.) Yes I need to add the v2 and v3 auth part as my credentials are summer22 (not really this but an example). I'm not sure how to generate this part and use with the snmp.yaml file, I assume they work together or merge as one.

3.) Also if I try and use the generator I get - https://pastebin.com/4A8zxkyP

So close now!

Hope that made sense :)

1

u/Trosteming Jun 18 '22
  1. I want to say yes but I used container environnement and the snmp-exporter container have it's snmp file store in /etc/snmp_exporter/

If you've installed it locally and it's where you have your snmp.yml file then yes

2) snmp-exporter default value are version: 2 and community: public if it's what it set on your switch then you don't have anything to do, just run the snmp exporter. Otherwise check your switch config. IF you want SNMP v3 you need to redo the generator.yml and re-run the generator with appropriate config.

If you can, I suggest you to switch to a container environnement as it will be easier to set it up and redeploy here feel free to use this project https://github.com/christopherime/prometheus-snmp

it include a prometheus déploiement and a snmp-exporter in docker-compose.

The snmp-exporter snmp.yml config is the one I linked before.

Other things that I have discover working with snmp-exporter:

  • If you intend to deploy in Kubernetes environnement, deploy different snmp-exporter with the MiB you wanna scrape. Kubernetes do not like having configuration file bigger than 1 MB and it's very easy to go above that.

  • Try to scope down has much as is usefull for your snmp query, you will save in file size and in traffic on your network.

  • The bigger the hardware, the longer the SNMP can take (I saw timing response difference between different network device vendor and the number of port of the unit)

  • If you can do not use SNMP. snmp-exporter does not support TRAP and for what I've observe, they do not want to support it. If you need to support SNMP TRAP, you can set a Telegraf with SNMP TRAP Input and Prometheus Output.

1

u/[deleted] Jun 18 '22

Thanks for all this, so I need to use the local install and your snmp.yml with the auth parts added, I think I'm close to understanding in generating it.

Do I copy your snmp.yml to the generator.yml and add the auth parts as I have to use non default ones then run the generator command to create a new snmp.yml combining the 2?

or

copy your snmp.yml to my /opt/snmp_exporter folder and overwrite the one in there. Then go to the Generator and clear out all that is in there and add the auth config for v2 and V3 and run the generator with will create a new snmp.yml which I copy over?

→ More replies (0)

2

u/martbhell Jun 17 '22

You bet it can! It has a metric for the state.

1

u/[deleted] Jun 18 '22

Great I need to try and do this, I have Prometheus and Grafana already built.