Introduction
Network switches are critical components of any infrastructure. Monitoring interface bandwidth, device uptime, and fault conditions helps administrators proactively identify issues before they impact production.
In this guide, we’ll build a complete monitoring solution using:
- SNMP-enabled Switch
- SNMP Exporter
- Prometheus
- Grafana
Step 1: Verify SNMP Connectivity
Before configuring monitoring, verify that SNMP is enabled and accessible from your monitoring server.
Run:
snmpwalk -v2c -c public x.x.x.x
Expected Result:
• SNMP OIDs should be returned successfully.
• If no response is received, verify:
o SNMP service is enabled on the switch.
o Community string is correct.
o Firewall rules allow UDP 161.
Step 2: Install SNMP Exporter
Download the exporter:
cd /tmp
wget https://github.com/prometheus/snmp_exporter/releases/download/v0.25.0/snmp_exporter-0.25.0.linux-amd64.tar.gz
Extract:
tar -xvf snmp_exporter-0.25.0.linux-amd64.tar.gz
cd snmp_exporter-0.25.0.linux-amd64
Copy binary and configuration:
sudo mkdir -p /etc/snmp_exporter
sudo cp snmp.yml /etc/snmp_exporter/
sudo cp snmp_exporter /usr/local/bin/
sudo chmod +x /usr/local/bin/snmp_exporter
Step 3: Configure SNMP Exporter as a Systemd Service
Create service file:
sudo nano /etc/systemd/system/snmp_exporter.service
Paste:
[Unit]
Description=SNMP Exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/snmp_exporter --config.file=/etc/snmp_exporter/snmp.yml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Save and exit.
Step 4: Reload Systemd
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
Step 5: Start SNMP Exporter
sudo systemctl start snmp_exporter
Step 6: Enable Auto Start
sudo systemctl enable snmp_exporter
Step 7: Verify Service Status
sudo systemctl status snmp_exporter
Expected:
Active: active (running)
Step 8: Verify Listening Port
SNMP Exporter listens on port 9116 by default.
netstat -tulnp | grep 9116
Expected:
:9116 LISTEN
Step 9: Test SNMP Exporter
Run:
curl "http://localhost:9116/snmp?target=x.x.x.x&module=if_mib"
Expected output should contain metrics such as:
ifHCInOctets
ifHCOutOctets
This confirms that SNMP Exporter can successfully query the switch.
Troubleshooting
If the service does not start:
journalctl -u snmp_exporter -f
Common issues:
- Invalid snmp.yml configuration
- Incorrect file permissions
- Port already in use
- Firewall restrictions
Step 10: Configure Prometheus
Edit Prometheus configuration:
sudo nano /etc/prometheus/prometheus.yml
Add the following jobs.
Interface Metrics
- job_name: ‘snmp-switch’
metrics_path: /snmp
params:
module: \[if_mib\]static_configs:
- targets: - x.x.x.x - x.x.x.xrelabel_configs:
- source_labels: \[\__address_\_\] target_label: \__param_target - source_labels: \[\__param_target\] target_label: instance - target_label: \__address_\_ replacement: x.x.x.x:9116
System Metrics
- job_name: ‘snmp-system’
metrics_path: /snmp
params:
module: \[system\]static_configs:
- targets: - x.x.x.x //ip address - x.x.x.xrelabel_configs:
- source_labels: \[\__address_\_\] target_label: \__param_target - source_labels: \[\__param_target\] target_label: instance - target_label: \__address_\_ replacement: x.x.x.x:9116
Siemens Fault Monitoring
- job_name: ‘snmp-siemens-fault’
metrics_path: /snmp
params:
module: \[siemens_system\]static_configs:
- targets: - x.x.x.x - x.x.x.xrelabel_configs:
- source_labels: \[\__address_\_\] target_label: \__param_target - source_labels: \[\__param_target\] target_label: instance - target_label: \__address_\_ replacement: x.x.x.x:9116
Step 11: Restart Prometheus
sudo systemctl restart prometheus
Verify:
sudo systemctl status prometheus
Expected:
Active: active (running)
Step 12: Validate Targets
Open Prometheus:
http://<prometheus-server>:9090/targets
All SNMP jobs should display:
State = UP
Step 13: Create Grafana Dashboard
Add Prometheus as a datasource if not already configured.
Useful metrics include:
Interface Traffic
rate(ifHCInOctets[5m]) * 8
Inbound bandwidth.
rate(ifHCOutOctets[5m]) * 8
Outbound bandwidth.
Interface Status
ifOperStatus
Monitor interface up/down status.
Device Uptime
sysUpTime
Fault Monitoring
Use metrics generated from the Siemens SNMP module to create:
- Fault count panels
- Critical alarm panels
- Device health overview
Alerting dashboards
Benefits of This Architecture
- Agentless monitoring
- Supports almost all network devices
- Scalable for hundreds of switches
- Centralized monitoring through Grafana
- Historical performance analysis
- Real-time fault visibility
- Easy integration with existing Prometheus environments
Conclusion
Using SNMP Exporter with Prometheus and Grafana provides a powerful and scalable solution for monitoring network infrastructure. By collecting interface statistics, system health metrics, and fault information, administrators gain complete visibility into switch performance and can quickly respond to issues before they affect operations.



