SNMP is used to monitor many different devices like routers, UPSs, Storages, etc… The ultimate SRE startegy is to inify all monitoring systems into one observability platform and get unique place where you see all info needed in case of emergency.
Here is how you can use OpenTelemetry to collect SNMP data from your devices and send it to Prometheus or Mimir. Then you can use Grafana to visualize and create alerts.
Setup
Use Prometheus snmp_exporter to query SNMP devices because it will automatically handle translations of MIBs to metrics. Some other options are also available but yo umay need to do the mapping manually.
One snmp_exporter can query multiple targets and you can isntruct Prometheus or Mimir to scrape only snmp_exporter.
In Linux, you can:
# Server
apt install snmpd
# Tools
apt install snmp
Configure SNMP Server
# IF-MIB in /etc/snmp/snmpd.conf
view systemview included .1.3.6.1.2.1.2
# Restart SNMPd
service snmpd restart
Test SNMP Server
curl http://localhost:9116/snmp?target=YOUR.SNMP.SERVER
You should get similar result:
# HELP ifAdminStatus The desired state of the interface - 1.3.6.1.2.1.2.2.1.7
# TYPE ifAdminStatus gauge
ifAdminStatus{ifAlias="",ifDescr="Red Hat, Inc. Device 0001",ifIndex="2",ifName=""} 1
ifAdminStatus{ifAlias="",ifDescr="Red Hat, Inc. Device 0001",ifIndex="3",ifName=""} 1
ifAdminStatus{ifAlias="",ifDescr="docker0",ifIndex="4",ifName=""} 1
ifAdminStatus{ifAlias="",ifDescr="lo",ifIndex="1",ifName=""} 1
# HELP ifInDiscards The number of inbound packets which were chosen to be discarded even though no errors had been detected to prevent their being deliverable to a higher-layer protocol - 1.3.6.1.2.1.2.2.1.13
# TYPE ifInDiscards counter
ifInDiscards{ifAlias="",ifDescr="Red Hat, Inc. Device 0001",ifIndex="2",ifName=""} 0
ifInDiscards{ifAlias="",ifDescr="Red Hat, Inc. Device 0001",ifIndex="3",ifName=""} 0
Prometheus SNMP Exporter
You can instruct snmp_exporter to listen on all network interfaces by passing –web.listen-address=“0.0.0.0:9116” and then you can query it from browser:
http://your.ip.address:9116/snmp?target=127.0.0.1&auth=public_v2&module=if_mib