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 version number you want to install.
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 (e.g., 0.23.0).
wget https://github.com/prometheus/snmp_exporter/releases/download/v<VERSION>/snmp_exporter-<VERSION>.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/
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-0.23.0.linux-amd64.tar.gz
cd snmp_exporter-0.23.0.linux-amd64
Move the Binary:
sudo mv snmp_exporter /usr/local/bin/
Step 2: Configure SNMP Exporter
Create the SNMP Config File:
Define the SNMP modules in a file named snmp.yml
. 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
. If the directory doesn’t exist, create it:
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:
Edit 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
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 (e.g., 0.23.0
).
wget https://github.com/prometheus/snmp_exporter/releases/download/v<VERSION>/snmp_exporter-<VERSION>.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:
Define the SNMP modules in a file named snmp.yml
. 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
. If the directory doesn’t exist, create it:
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:
Edit 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
This should now be ready for use with Prometheus!