Listening to SNMP traps

Prerequisites

To start listening to SNMP traps

  1. 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 following public community string in the /etc/snmp/snmptrapd.conf file:

    authCommunity log,execute,net public
    
  2. Configure the firewall to allow inbound traffic on UDP port 162.
  3. Download the VSTORAGE-MIB.txt file and place it in the /usr/share/snmp/mibs directory.
  4. 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
    
  5. Send a test trap from the Settings > System settings > SNMP tab in the admin panel.
  6. 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