Listening to SNMP traps
Prerequisites
- The SNMP access is enabled, as described in Enabling SNMP access.
To start listening to SNMP traps
-
Configure the
snmptrapd
daemon to log SNMP traps, allow them to trigger executable actions, and resend data to the network. To do this, uncomment the followingpublic
community string in the /etc/snmp/snmptrapd.conf file:authCommunity log,execute,net public
- Configure the firewall to allow inbound traffic on UDP port 162.
- Download the VSTORAGE-MIB.txt file and place it in the /usr/share/snmp/mibs directory.
-
Start the daemon and specify the MIB file:
# snmptrapd -M /usr/share/snmp/mibs -m VSTORAGE-MIB -n -f
By default, traps will be logged to /var/log/messages. You can redirect them to a custom log file with the
-Lf <path>
option. For example:# snmptrapd -M /usr/share/snmp/mibs -m VSTORAGE-MIB -n -f -Lf /tmp/traps.log
- Send a test trap from the Settings > System settings > SNMP tab in the admin panel.
-
View the log file:
# tail -f /tmp/traps.log 2019-10-14 12:51:50 node001.vstoragedomain [UDP: [10.94.80.22]:40029->\ [10.94.80.22]:162]:#012DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: \ (111150521) 12 days, 20:45:05.21#011SNMPv2-MIB::snmpTrapOID.0 = OID: \ NET-SNMP-MIB::netSnmp.161.3.100#011NET-SNMP-MIB::netSnmp.161.2.1 = STRING: "TestTrap"\ #011NET-SNMP-MIB::netSnmp.161.2.2 = STRING: "It is the test trap from VStorage"\ #011NET-SNMP-MIB::netSnmp.161.2.3 = Counter64: 0