Skip to content

SNMP: target-side setup ​

The SNMP sensors (interface, CPU, memory, uptime, disk, custom OID, custom table and UPS) only ever send GET and GETNEXT/GETBULK requests. Give them read-only access, and limit what that access can read. Probeward speaks SNMP version 2c and version 3 (noAuthNoPriv, authNoPriv and authPriv). Prefer version 3 with authentication and privacy; version 2c sends its community in clear text.

net-snmp (Linux and most Unix systems) ​

Install the agent: apt install snmpd, dnf install net-snmp, apk add net-snmp, pacman -S net-snmp.

Which parts of the tree ​

The sensors read these subtrees. A view that includes them and nothing more is enough:

SubtreeUsed by
.1.3.6.1.2.1.1 systemuptime, discovery
.1.3.6.1.2.1.2, .1.3.6.1.2.1.31 interfacesinterface traffic
.1.3.6.1.2.1.25 host resourcesCPU, memory, disk, uptime
.1.3.6.1.2.1.33 UPS-MIBUPS
.1.3.6.1.4.1.2021 UCD-SNMPCPU and memory on net-snmp
.1.3.6.1.6.3.10.2.1 SNMP engineuptime fallback, v3

For a custom OID or table sensor, add the subtree it reads.

SNMPv3 user ​

In /etc/snmp/snmpd.conf (the location differs on some systems):

text
agentaddress udp:161
view probeward included .1.3.6.1.2.1
view probeward included .1.3.6.1.4.1.2021
view probeward included .1.3.6.1.6.3.10.2.1
rouser probeward authPriv -V probeward

Create the user with the helper that ships with net-snmp. It writes the user, with its keys, to the agent's persistent store, so stop the agent first:

sh
sudo systemctl stop snmpd
sudo net-snmp-create-v3-user -ro -A 'a long authentication passphrase' -a SHA \
                                  -X 'a long privacy passphrase'       -x AES  probeward
sudo systemctl start snmpd

(If the helper is not installed, put createUser probeward SHA "auth passphrase" AES "priv passphrase" in /var/lib/snmp/snmpd.conf while the agent is stopped; the agent replaces the line with the localised keys.) Passphrases must be at least 8 characters. -a SHA and -x AES match Probeward's sha1 and aes128; the credential form also offers md5, sha256, sha512, des and aes256, when your agent supports them. In Probeward create a credential of kind snmp_v3 with level authPriv, user probeward, and the two passphrases.

Check what the helper added. -ro makes net-snmp-create-v3-user append a bare rouser probeward line to a configuration file, and a bare rouser line has no view and no required security level. It was checked in real containers with the configuration above in /etc/snmp/snmpd.conf and the helper run as shown:

Distributionnet-snmpThe helper appended rouser probeward tocreateUser went to
Debian 135.9.4/etc/snmp/snmpd.conf/var/lib/snmp/snmpd.conf
Rocky Linux 105.9.4/etc/snmp/snmpd.conf/var/lib/net-snmp/snmpd.conf
Alpine 3.245.9.5/usr/share/snmp/snmpd.conf (Alpine's helper also prints a harmless ps usage message)/var/lib/net-snmp/snmpd.conf

On all three, afterwards, the user could read the whole tree at the authNoPriv level, without privacy: ifNumber, which is outside the view, answered, and so would everything else. At the authPriv level the view still held (ifNumber was refused and sysName was answered), because your own rouser probeward authPriv -V probeward line is chosen for that level. So the view restriction and the encryption you wanted can be bypassed by anyone who holds the authentication passphrase. The same result was reproduced with a scratch snmpd (net-snmp 5.9.5), with the bare line before and after yours. Look for it and remove it:

sh
sudo grep -rn '^rouser' /etc/snmp /usr/share/snmp

Keep only your own line (rouser probeward authPriv -V probeward, or rouser probeward priv -V probeward), then restart the agent and check that the weaker level is refused. This must fail (Error in packet, authorizationError or no answer), while the same command with -l authPriv -x AES -X ... works (on Debian 13, deleting the line and restarting the agent gave authorizationError (access denied to that object) at authNoPriv and kept authPriv working):

sh
snmpget -v3 -l authNoPriv -u probeward -a SHA -A 'a long authentication passphrase' \
        192.0.2.20 1.3.6.1.2.1.2.1.0

Without the helper there is nothing to clean up: use the createUser line above instead.

A wrong user name or passphrase is silent on the wire: the agent does not answer. Probeward tells that apart from a dead agent (see snmp_interface).

SNMPv2c community ​

text
agentaddress udp:161
view probeward included .1.3.6.1.2.1
view probeward included .1.3.6.1.4.1.2021
rocommunity a-long-random-string 192.0.2.0/24 -V probeward

192.0.2.0/24 is the address of the probe host or its network. Never use public. A community is a password that crosses the network in clear text, so use v2c only on a network you trust.

Check it from the probe host ​

sh
snmpget -v3 -l authPriv -u probeward -a SHA -A 'auth passphrase' -x AES -X 'priv passphrase' \
        192.0.2.20 1.3.6.1.2.1.1.3.0
snmpwalk -v2c -c a-long-random-string 192.0.2.20 1.3.6.1.2.1.25.2.3.1.3     # storage descriptions

Disk and memory on net-snmp ​

The Host Resources storage table makes the agent run statfs on every mounted filesystem, and one stalled network or FUSE mount can then block the agent. The memory sensor therefore prefers the UCD memory group, which reads /proc/meminfo only. If you only need a few disks, add ignoreDisk or includeAllDisks lines for the UCD disk table, or watch the disks with the SSH disk sensor, which asks df about one path.

Network devices and UPS cards ​

Switches, routers, firewalls and UPS management cards each have their own screen or command for SNMP. What you need is the same: a version 3 user with authentication and privacy and read-only access, or a v2c read-only community limited to the probe host's address; the agent reachable on UDP 161 from the probe host. For a UPS card the UPS-MIB (RFC 1628) must be enabled; some cards need a setting for it. Many devices list interfaces only under ifXTable for 64-bit counters, which the interface sensor uses where it is there.

Windows ​

The Windows SNMP service is not recommended. Monitor Windows hosts over WinRM instead, or over native WMI from a Windows probe.

Firewalls and ports ​

UDP 161 from the probe host to the device. SNMP replies go back to the source port, which stateful firewalls allow. If the sensors time out with the right credential, a firewall or an ACL on the agent is the usual cause.

AGPL-3.0-only