SNMP Exporter Installation Guide
Introduction
This guide provides step-by-step instructions for installing the Prometheus SNMP Exporter on various platforms. The SNMP Exporter allows Prometheus to monitor network devices like routers, switches, firewalls, and other SNMP-enabled infrastructure.
Official Repository: SNMP Exporter on GitHub
What You’ll Need
Before starting the installation, ensure you have:
- A Linux, macOS, or Windows system
- Root or sudo access (for Linux/macOS)
- Internet connection for downloading packages
- Basic command-line knowledge
- A working Prometheus installation (see Prometheus installation guide)
Installation Method 1: Binary Installation (Linux)
This is the recommended method for production environments.
Step 1: Create User and Directories
First, create a dedicated user for the SNMP Exporter:
# Create snmp_exporter user (no login shell)
sudo useradd --no-create-home --shell /bin/false snmp_exporter
# Create configuration directory
sudo mkdir -p /etc/snmp_exporter
# Set proper ownership
sudo chown snmp_exporter:snmp_exporter /etc/snmp_exporter
Step 2: Download the Latest Release
Visit the releases page to find the latest version.
# Set version (check GitHub for the latest)
VERSION="0.26.0"
# Download for Linux AMD64
cd /tmp
wget https://github.com/prometheus/snmp_exporter/releases/download/v${VERSION}/snmp_exporter-${VERSION}.linux-amd64.tar.gz
# Verify the download
ls -lh snmp_exporter-${VERSION}.linux-amd64.tar.gz
Step 3: Extract and Install
# Extract the archive
tar xvfz snmp_exporter-${VERSION}.linux-amd64.tar.gz
# Navigate to the extracted directory
cd snmp_exporter-${VERSION}.linux-amd64
# Copy the binary to system path
sudo cp snmp_exporter /usr/local/bin/
# Set proper ownership and permissions
sudo chown snmp_exporter:snmp_exporter /usr/local/bin/snmp_exporter
sudo chmod 755 /usr/local/bin/snmp_exporter
# Verify installation
/usr/local/bin/snmp_exporter --version
Step 4: Install Configuration File
# Copy default configuration
sudo cp snmp.yml /etc/snmp_exporter/
# Set proper ownership
sudo chown snmp_exporter:snmp_exporter /etc/snmp_exporter/snmp.yml
sudo chmod 644 /etc/snmp_exporter/snmp.yml
# Verify configuration file
sudo ls -l /etc/snmp_exporter/
Step 5: Create Systemd Service
Create a systemd service file for automatic startup and management:
sudo nano /etc/systemd/system/snmp_exporter.service
Add the following configuration:
[Unit]
Description=Prometheus SNMP Exporter
Documentation=https://github.com/prometheus/snmp_exporter
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=snmp_exporter
Group=snmp_exporter
ExecStart=/usr/local/bin/snmp_exporter \
--config.file=/etc/snmp_exporter/snmp.yml \
--web.listen-address=:9116
Restart=on-failure
RestartSec=5
# Security hardening
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=/etc/snmp_exporter
[Install]
WantedBy=multi-user.target
Save and exit (Ctrl+X, Y, Enter).
Step 6: Start and Enable the Service
# Reload systemd to recognize the new service
sudo systemctl daemon-reload
# Start the SNMP Exporter
sudo systemctl start snmp_exporter
# Enable automatic start on boot
sudo systemctl enable snmp_exporter
# Check the service status
sudo systemctl status snmp_exporter
You should see output indicating the service is active and running.
Step 7: Verify Installation
# Check if the exporter is listening on port 9116
sudo netstat -tulpn | grep 9116
# Or using ss command
sudo ss -tulpn | grep 9116
# Test the exporter endpoint
curl http://localhost:9116/metrics
Installation Method 2: Binary Installation (Ubuntu/Debian)
For Debian-based systems, you can also use this streamlined approach:
Quick Installation Script
#!/bin/bash
# Set version
VERSION="0.26.0"
# Update package list
sudo apt-get update
# Install required tools
sudo apt-get install -y wget tar
# Create user and directories
sudo useradd --no-create-home --shell /bin/false snmp_exporter
sudo mkdir -p /etc/snmp_exporter
# Download and extract
cd /tmp
wget https://github.com/prometheus/snmp_exporter/releases/download/v${VERSION}/snmp_exporter-${VERSION}.linux-amd64.tar.gz
tar xvfz snmp_exporter-${VERSION}.linux-amd64.tar.gz
cd snmp_exporter-${VERSION}.linux-amd64
# Install binary and config
sudo cp snmp_exporter /usr/local/bin/
sudo cp snmp.yml /etc/snmp_exporter/
sudo chown snmp_exporter:snmp_exporter /usr/local/bin/snmp_exporter
sudo chown -R snmp_exporter:snmp_exporter /etc/snmp_exporter
# Create systemd service (paste the service file content from above)
# Then run:
sudo systemctl daemon-reload
sudo systemctl start snmp_exporter
sudo systemctl enable snmp_exporter
sudo systemctl status snmp_exporter
echo "SNMP Exporter installation complete!"
Installation Method 3: Binary Installation (CentOS/RHEL)
Step 1: Install Prerequisites
# Update system packages
sudo yum update -y
# Install required tools
sudo yum install -y wget tar
Step 2: Download and Install
# Set version
VERSION="0.26.0"
# Create user and directories
sudo useradd --no-create-home --shell /bin/false snmp_exporter
sudo mkdir -p /etc/snmp_exporter
# Download for Linux AMD64
cd /tmp
wget https://github.com/prometheus/snmp_exporter/releases/download/v${VERSION}/snmp_exporter-${VERSION}.linux-amd64.tar.gz
# Extract
tar xvfz snmp_exporter-${VERSION}.linux-amd64.tar.gz
cd snmp_exporter-${VERSION}.linux-amd64
# Install binary and configuration
sudo cp snmp_exporter /usr/local/bin/
sudo cp snmp.yml /etc/snmp_exporter/
sudo chown snmp_exporter:snmp_exporter /usr/local/bin/snmp_exporter
sudo chown -R snmp_exporter:snmp_exporter /etc/snmp_exporter
Step 3: Configure Firewall
# Allow SNMP Exporter port
sudo firewall-cmd --permanent --add-port=9116/tcp
sudo firewall-cmd --reload
# Verify
sudo firewall-cmd --list-ports
Step 4: Create and Start Service
Follow Step 5 and Step 6 from the Linux installation above to create and start the systemd service.
Installation Method 4: Docker Installation
Docker provides the fastest way to get started with SNMP Exporter.
Prerequisites
Install Docker by following the official Docker installation guide.
Step 1: Create Configuration Directory
# Create directory for configuration
mkdir -p ~/snmp_exporter
cd ~/snmp_exporter
Step 2: Download Configuration File
# Download the default snmp.yml
wget https://raw.githubusercontent.com/prometheus/snmp_exporter/main/snmp.yml
# Or create a minimal configuration
cat > snmp.yml <<EOF
# Minimal SNMP Exporter configuration
auths:
public_v2:
community: public
security_level: noAuthNoPriv
version: 2
modules:
if_mib:
walk:
- 1.3.6.1.2.1.2.2.1.2 # ifDescr
- 1.3.6.1.2.1.2.2.1.5 # ifSpeed
- 1.3.6.1.2.1.2.2.1.8 # ifOperStatus
EOF
Step 3: Run Docker Container
docker run -d \
--name snmp-exporter \
--restart unless-stopped \
-p 9116:9116 \
-v $(pwd)/snmp.yml:/etc/snmp_exporter/snmp.yml:ro \
prom/snmp-exporter:latest \
--config.file=/etc/snmp_exporter/snmp.yml
Step 4: Verify Docker Container
# Check if container is running
docker ps | grep snmp-exporter
# View logs
docker logs snmp-exporter
# Follow logs in real-time
docker logs -f snmp-exporter
# Test the exporter
curl http://localhost:9116/metrics
Docker Container Management
# Stop the container
docker stop snmp-exporter
# Start the container
docker start snmp-exporter
# Restart the container
docker restart snmp-exporter
# Remove the container
docker rm -f snmp-exporter
# Update to latest image
docker pull prom/snmp-exporter:latest
docker rm -f snmp-exporter
# Then re-run the docker run command from Step 3
Installation Method 5: Docker Compose
For easier management and integration with other services.
Step 1: Create Project Directory
mkdir -p ~/snmp-monitoring
cd ~/snmp-monitoring
Step 2: Create Configuration File
# Download or create snmp.yml
wget https://raw.githubusercontent.com/prometheus/snmp_exporter/main/snmp.yml
Step 3: Create Docker Compose File
nano docker-compose.yml
Add the following content:
version: '3.8'
services:
snmp-exporter:
image: prom/snmp-exporter:latest
container_name: snmp-exporter
restart: unless-stopped
ports:
- "9116:9116"
volumes:
- ./snmp.yml:/etc/snmp_exporter/snmp.yml:ro
command:
- '--config.file=/etc/snmp_exporter/snmp.yml'
- '--log.level=info'
networks:
- monitoring
networks:
monitoring:
driver: bridge
Step 4: Start Services
# Start in detached mode
docker-compose up -d
# View logs
docker-compose logs -f
# Check status
docker-compose ps
Step 5: Manage Services
# Stop services
docker-compose stop
# Start services
docker-compose start
# Restart services
docker-compose restart
# Stop and remove containers
docker-compose down
# Stop and remove containers including volumes
docker-compose down -v
# Update to latest images
docker-compose pull
docker-compose up -d
Installation Method 6: macOS Installation
Using Homebrew (Recommended)
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install SNMP Exporter (if available in tap)
# Note: May not be in official Homebrew, use binary method below if unavailable
brew install snmp_exporter
Binary Installation for macOS
# Set version
VERSION="0.26.0"
# Download for macOS AMD64
cd /tmp
curl -LO https://github.com/prometheus/snmp_exporter/releases/download/v${VERSION}/snmp_exporter-${VERSION}.darwin-amd64.tar.gz
# Extract
tar xvfz snmp_exporter-${VERSION}.darwin-amd64.tar.gz
cd snmp_exporter-${VERSION}.darwin-amd64
# Create directories
sudo mkdir -p /usr/local/etc/snmp_exporter
sudo mkdir -p /usr/local/var/log/snmp_exporter
# Install binary
sudo cp snmp_exporter /usr/local/bin/
sudo cp snmp.yml /usr/local/etc/snmp_exporter/
# Verify installation
snmp_exporter --version
Create LaunchAgent (macOS Service)
# Create LaunchAgent plist
sudo nano /Library/LaunchDaemons/io.prometheus.snmp_exporter.plist
Add the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.prometheus.snmp_exporter</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/snmp_exporter</string>
<string>--config.file=/usr/local/etc/snmp_exporter/snmp.yml</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/snmp_exporter/error.log</string>
<key>StandardOutPath</key>
<string>/usr/local/var/log/snmp_exporter/output.log</string>
</dict>
</plist>
Start the Service
# Load the service
sudo launchctl load /Library/LaunchDaemons/io.prometheus.snmp_exporter.plist
# Start the service
sudo launchctl start io.prometheus.snmp_exporter
# Check status
sudo launchctl list | grep snmp_exporter
# View logs
tail -f /usr/local/var/log/snmp_exporter/output.log
Installation Method 7: Windows Installation
Step 1: Download Binary
- Visit the releases page
- Download the Windows binary:
snmp_exporter-{VERSION}.windows-amd64.tar.gz - Extract the archive using 7-Zip or Windows built-in extraction
Step 2: Create Installation Directory
# Open PowerShell as Administrator
New-Item -ItemType Directory -Path "C:\Program Files\snmp_exporter"
New-Item -ItemType Directory -Path "C:\Program Files\snmp_exporter\config"
Step 3: Copy Files
# Copy binary and config
Copy-Item -Path ".\snmp_exporter.exe" -Destination "C:\Program Files\snmp_exporter\"
Copy-Item -Path ".\snmp.yml" -Destination "C:\Program Files\snmp_exporter\config\"
Step 4: Create Windows Service
Using NSSM (Non-Sucking Service Manager):
# Download NSSM from https://nssm.cc/download
# Extract and navigate to nssm directory
# Install service
.\nssm.exe install SNMPExporter "C:\Program Files\snmp_exporter\snmp_exporter.exe"
# Set arguments
.\nssm.exe set SNMPExporter AppParameters "--config.file=C:\Program Files\snmp_exporter\config\snmp.yml"
# Set startup directory
.\nssm.exe set SNMPExporter AppDirectory "C:\Program Files\snmp_exporter"
# Start service
.\nssm.exe start SNMPExporter
Step 5: Configure Firewall
# Allow inbound traffic on port 9116
New-NetFirewallRule -DisplayName "SNMP Exporter" -Direction Inbound -LocalPort 9116 -Protocol TCP -Action Allow
Post-Installation Configuration
Basic Configuration File
The default snmp.yml includes many pre-configured modules. Here’s a minimal example:
auths:
public_v2:
community: public
security_level: noAuthNoPriv
version: 2
modules:
if_mib:
walk:
- 1.3.6.1.2.1.2.2.1.2 # ifDescr
- 1.3.6.1.2.1.2.2.1.5 # ifSpeed
- 1.3.6.1.2.1.2.2.1.8 # ifOperStatus
- 1.3.6.1.2.1.31.1.1.1.6 # ifHCInOctets
- 1.3.6.1.2.1.31.1.1.1.10 # ifHCOutOctets
Configure Prometheus
Add the following to your prometheus.yml:
scrape_configs:
- job_name: 'snmp'
static_configs:
- targets:
- 192.168.1.1 # SNMP device IP
metrics_path: /snmp
params:
module: [if_mib]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9116 # SNMP Exporter address
Reload Prometheus
# Binary installation
sudo systemctl reload prometheus
# Docker installation
docker exec prometheus kill -HUP 1
# Or restart
docker restart prometheus
Verification and Testing
Test SNMP Connectivity
Before using the exporter, verify SNMP access to your devices:
# Install snmpwalk (if not already installed)
# Ubuntu/Debian
sudo apt-get install snmp snmp-mibs-downloader
# CentOS/RHEL
sudo yum install net-snmp-utils
# macOS
brew install net-snmp
# Test SNMP v2c
snmpwalk -v2c -c public 192.168.1.1 system
# Test SNMP v3
snmpwalk -v3 -l authPriv -u username -a SHA -A authpass -x AES -X privpass 192.168.1.1 system
Test SNMP Exporter
# Query the exporter directly
curl 'http://localhost:9116/snmp?target=192.168.1.1&module=if_mib'
# You should see Prometheus-formatted metrics
Check Prometheus Targets
- Open Prometheus web UI:
http://localhost:9090 - Navigate to Status → Targets
- Verify your SNMP targets show as “UP”
- Check “Last Scrape” time
Run Test Queries in Prometheus
# Check if metrics are being collected
up{job="snmp"}
# View interface status
ifOperStatus
# Check interface traffic (if available)
rate(ifHCInOctets[5m])
Service Management Commands
Linux (systemd)
# Start service
sudo systemctl start snmp_exporter
# Stop service
sudo systemctl stop snmp_exporter
# Restart service
sudo systemctl restart snmp_exporter
# Check status
sudo systemctl status snmp_exporter
# Enable auto-start on boot
sudo systemctl enable snmp_exporter
# Disable auto-start
sudo systemctl disable snmp_exporter
# View logs
sudo journalctl -u snmp_exporter -f
# View recent logs
sudo journalctl -u snmp_exporter -n 100
# Reload configuration (send SIGHUP)
sudo systemctl reload snmp_exporter
Docker
# Start container
docker start snmp-exporter
# Stop container
docker stop snmp-exporter
# Restart container
docker restart snmp-exporter
# View logs
docker logs -f snmp-exporter
# Execute commands inside container
docker exec snmp-exporter snmp_exporter --version
# Update container
docker pull prom/snmp-exporter:latest
docker stop snmp-exporter
docker rm snmp-exporter
# Re-run docker run command
macOS
# Start service
sudo launchctl start io.prometheus.snmp_exporter
# Stop service
sudo launchctl stop io.prometheus.snmp_exporter
# Unload service
sudo launchctl unload /Library/LaunchDaemons/io.prometheus.snmp_exporter.plist
# Load service
sudo launchctl load /Library/LaunchDaemons/io.prometheus.snmp_exporter.plist
# View logs
tail -f /usr/local/var/log/snmp_exporter/output.log
Windows
# Start service
Start-Service SNMPExporter
# Stop service
Stop-Service SNMPExporter
# Restart service
Restart-Service SNMPExporter
# Check status
Get-Service SNMPExporter
# Using NSSM
nssm start SNMPExporter
nssm stop SNMPExporter
nssm restart SNMPExporter
nssm status SNMPExporter
Troubleshooting Installation
Issue: Service Won’t Start
Check logs:
# Linux
sudo journalctl -u snmp_exporter -n 50 --no-pager
# Docker
docker logs snmp-exporter
Common causes:
- Configuration file syntax errors
- Port 9116 already in use
- Incorrect file permissions
Solutions:
# Check port usage
sudo netstat -tulpn | grep 9116
sudo lsof -i :9116
# Verify configuration syntax
/usr/local/bin/snmp_exporter --config.check --config.file=/etc/snmp_exporter/snmp.yml
# Check file permissions
ls -l /etc/snmp_exporter/snmp.yml
sudo chown snmp_exporter:snmp_exporter /etc/snmp_exporter/snmp.yml
Issue: Cannot Access Web Interface
Check if service is running:
# Linux
sudo systemctl status snmp_exporter
# Docker
docker ps | grep snmp-exporter
Verify port binding:
curl http://localhost:9116/metrics
Check firewall:
# Linux (UFW)
sudo ufw allow 9116/tcp
# Linux (firewalld)
sudo firewall-cmd --permanent --add-port=9116/tcp
sudo firewall-cmd --reload
# macOS
# Usually no firewall configuration needed for localhost
Issue: Permission Denied Errors
# Fix ownership
sudo chown -R snmp_exporter:snmp_exporter /etc/snmp_exporter
sudo chown snmp_exporter:snmp_exporter /usr/local/bin/snmp_exporter
# Fix permissions
sudo chmod 755 /usr/local/bin/snmp_exporter
sudo chmod 644 /etc/snmp_exporter/snmp.yml
Issue: Module or Configuration Not Found
# Verify configuration file location
ls -l /etc/snmp_exporter/snmp.yml
# Check configuration syntax
/usr/local/bin/snmp_exporter --config.check --config.file=/etc/snmp_exporter/snmp.yml
# Download default configuration if missing
sudo wget -O /etc/snmp_exporter/snmp.yml https://raw.githubusercontent.com/prometheus/snmp_exporter/main/snmp.yml
sudo chown snmp_exporter:snmp_exporter /etc/snmp_exporter/snmp.yml
Issue: High Memory Usage
If the exporter is consuming too much memory:
# Restart the service
sudo systemctl restart snmp_exporter
# Check for large configuration files
du -h /etc/snmp_exporter/snmp.yml
# Monitor resource usage
top -p $(pgrep snmp_exporter)
Uninstallation
Linux (Binary Installation)
# Stop and disable service
sudo systemctl stop snmp_exporter
sudo systemctl disable snmp_exporter
# Remove service file
sudo rm /etc/systemd/system/snmp_exporter.service
# Reload systemd
sudo systemctl daemon-reload
# Remove binary and configuration
sudo rm /usr/local/bin/snmp_exporter
sudo rm -rf /etc/snmp_exporter
# Remove user
sudo userdel snmp_exporter
Docker
# Stop and remove container
docker stop snmp-exporter
docker rm snmp-exporter
# Remove image
docker rmi prom/snmp-exporter:latest
# Remove configuration
rm -rf ~/snmp_exporter
macOS
# Stop and unload service
sudo launchctl stop io.prometheus.snmp_exporter
sudo launchctl unload /Library/LaunchDaemons/io.prometheus.snmp_exporter.plist
# Remove files
sudo rm /Library/LaunchDaemons/io.prometheus.snmp_exporter.plist
sudo rm /usr/local/bin/snmp_exporter
sudo rm -rf /usr/local/etc/snmp_exporter
sudo rm -rf /usr/local/var/log/snmp_exporter
Windows
# Stop and remove service (using NSSM)
nssm stop SNMPExporter
nssm remove SNMPExporter confirm
# Remove files
Remove-Item -Recurse -Force "C:\Program Files\snmp_exporter"
# Remove firewall rule
Remove-NetFirewallRule -DisplayName "SNMP Exporter"
Next Steps
After successful installation:
- Configure Authentication – Set up SNMPv2c or SNMPv3 credentials
- Add Device Targets – Configure Prometheus to scrape your network devices
- Create Custom Modules – Generate configurations for specific devices
- Set Up Alerting – Create alert rules for critical metrics
- Install Grafana – Visualize your SNMP metrics with dashboards
Further Reading:
Conclusion
You now have SNMP Exporter installed and ready to monitor your network infrastructure. The exporter is running and waiting for Prometheus to scrape metrics from your SNMP-enabled devices.
Happy Monitoring! 📊
Related Guides
Automating JNLP Downloads with PowerShell Using Session Cookies
When managing remote servers or BMC interfaces, some resources such as JNLP (Java Network Launch Protocol) files require authentication via cookies and session handling. Manually downloading these files can be cumbersome. PowerShell provides a way to automate this process using web sessions and cookie management. Creating a Persistent Web Session A web session in PowerShell […]
Complete Guide to Downloading Files with PowerShell
Introduction PowerShell provides powerful tools for downloading files from web servers, with Invoke-WebRequest being the primary cmdlet for making HTTP requests. This guide covers everything from basic downloads to advanced scenarios involving authentication, cookies, and custom headers. Basic File Downloads Simple Download The most straightforward way to download a file: Download with Progress Bar PowerShell […]
The Complete Guide to Installing StorCLI on Linux and Windows
StorCLI (Storage Command Line Tool) is Broadcom’s powerful command-line utility for managing LSI MegaRAID and PRAID controllers. Whether you’re managing hardware RAID arrays on servers or workstations, StorCLI provides comprehensive control over your storage infrastructure. This guide will walk you through the complete installation process on both Linux and Windows systems. What is StorCLI? StorCLI […]