Skip to content

Instantly share code, notes, and snippets.

@vladak
Created September 11, 2022 20:34
Show Gist options
  • Save vladak/eae9a33c4f1b4dd7d0c92aeea4a519a2 to your computer and use it in GitHub Desktop.
Save vladak/eae9a33c4f1b4dd7d0c92aeea4a519a2 to your computer and use it in GitHub Desktop.
SNMP exporter service

SNMP exporter service

This is meant for Debian/Ubuntu.

wget -O /tmp/snmp_exporter.tgz \
    https://github.com/prometheus/snmp_exporter/releases/download/v0.20.0/snmp_exporter-0.20.0.linux-armv7.tar.gz
sudo mkdir -p /srv/snmp_exporter
sudo chown pi:pi /srv/snmp_exporter
cd /srv/snmp_exporter
tar -xz --strip-components=1 -f /tmp/snmp_exporter.tgz
sudo cp ~/snmp/snmp.yml /srv/snmp_exporter
cat << EOF | sudo tee snmp_exporter.service
[Unit]
Description=SNMP Exporter
After=network-online.target

# This assumes you are running snmp_exporter under the user "prometheus"
[Service]
User=prometheus
Restart=on-failure
ExecStart=/srv/snmp_exporter/snmp_exporter --config.file='/srv/snmp_exporter/snmp.yml'

[Install]
WantedBy=multi-user.target
EOF
  • setup and enable the service
sudo cp /srv/snmp_exporter/snmp_exporter.service /etc/systemd/system/snmp_exporter.service
sudo systemctl enable snmp_exporter
sudo systemctl start snmp_exporter
sudo systemctl status snmp_exporter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment