Here’s how to properly install and set up the SNMP Exporter:
Step 1: Download and Install SNMP Exporter
- Download the SNMP Exporter: Visit the SNMP Exporter GitHub Releases to find the latest version. Replace
<VERSION>
in the commands below with the latest version number. Example for version 0.23.0:wget https://github.com/prometheus/snmp_exporter/releases/download/v0.23.0/snmp_exporter-0.23.0.linux-amd64.tar.gz
- Extract the Files:
tar -xvzf snmp_exporter-<VERSION>.linux-amd64.tar.gz cd snmp_exporter-<VERSION>.linux-amd64
- Move the Binary:
sudo mv snmp_exporter /usr/local/bin/
Step 2: Configure SNMP Exporter
- Create the SNMP Config File: The
snmp.yml
file should define the SNMP modules. Example configuration:modules: mikrotik: walk: - 1.3.6.1.2.1.1 # System OIDs version: 2c auth: community: public
Save this as/etc/snmp_exporter/snmp.yml
. Create the directory if it doesn’t exist:sudo mkdir -p /etc/snmp_exporter sudo nano /etc/snmp_exporter/snmp.yml
- Set Permissions:
sudo chown -R $USER:$USER /etc/snmp_exporter
Step 3: Create a Systemd Service
- Create the Service File:
sudo nano /etc/systemd/system/snmp_exporter.service
Add the following content:[Unit] Description=Prometheus SNMP Exporter After=network.target [Service] User=root ExecStart=/usr/local/bin/snmp_exporter --config.file=/etc/snmp_exporter/snmp.yml Restart=always [Install] WantedBy=multi-user.target
- Reload Systemd:
sudo systemctl daemon-reload
- Start and Enable the Service:
sudo systemctl start snmp_exporter sudo systemctl enable snmp_exporter