snmp-on-debian.md 1.8 KB

SNMP Monitoring on Debian/Debian downstream Linux distros

First, check if you have non-free added to your apt sources list. The snmp-mibs-downloader package cannot be obtained without non-free.

grep "non-free" /etc/apt/sources.list

If no results, simply append non-free to your /etc/apt/sources.list repo list, like so:

  • Before:

    deb http://ftp.us.debian.org/debian/ stretch main contrib
    deb-src http://ftp.us.debian.org/debian/ stretch main contrib
    
  • After:

    deb http://ftp.us.debian.org/debian/ stretch main non-free contrib
    deb-src http://ftp.us.debian.org/debian/ stretch main non-free contrib
    

Install SNMP and snmp-mibs-downloader

apt update && apt install snmpd snmp-mibs-downloader

SNMP Configuration

Adjust the SNMP config to listen on all interfaces

pico /etc/snmp/snmpd.conf

Change:

agentAddress udp:127.0.0.1:161

To:

agentAddress udp:161

Whitelist the monitoring IP(s)

rocommunity public [ip of the monitoring server]
  • If a custom community string is used in place of public, you must notify the monitoring server, else probes will fail.

Restart the SNMP daemon for the changes to take effect

service snmpd restart

Testing

From the monitoring server, trigger a probe and watch the local logs for activity

tail -f /var/log/syslog

Also do a UDP port scan of 161 to ensure it's responding (IP of the prober must be whitelisted as well, else you'll get a timeout)

nmap -sU -p 161 [ip of the target server]

From the whitelisted machine, you can also poll the SNMP directly

snmpwalk -c public -v1 [ip of the target server] | less

-c public may differ if you specified a custom community string for rocommunity in /etc/snmp/snmpd.conf