SNMPTrap monitoring is mainly used to monitor the active notification of equipment failure, such as storage monitoring of hard disk failure, network monitoring jitter.

The overall process description is as follows:
1. The monitored object sends SNMPTrap information to the snmptrapd(Net-SNMP) server.
2. The snmptrapd server sends the received SNMPTrap information to the SNMPTT (or Perl trap receiver).
3.SNMPTT (or Perl trap receiver) will write SNMPTrap information to SNMPTrapperFile in the specified data format.
4. The snmptrapper process of Zabbix server will read the content of SNMPTrapperFile, parse it, pass the value to the corresponding monitoring object, and save the data to DB.

If trap is not set to the value of any monitoring item, Zabbix default record does not match trap. (Configured by Log unmatched SNMP traps in Administration General Other.)

[Configuration steps]
Zabbix function configuration:

-- deploy Net-SNMP assembly
yum -y install net-snmp*
systemctl enable snmptrapd.service

-- SNMP Trap To configure
tar zxvf zabbix-3.4.15.tar.gz

cp /root/zabbix-3.4.15/misc/snmptrap/ /usr/bin/
chmod +x /usr/bin/

echo "# Modify by Eric.zhong at 20190904" >> /etc/snmp/snmptrapd.conf
echo authCommunity execute public >> /etc/snmp/snmptrapd.conf
echo perl do "/usr/bin/"; > /etc/snmp/snmptrapd.conf
tail -n 10 /etc/snmp/snmptrapd.conf
※ If more validation is required, separate validation can be added.[authCommunity execute zhong]To configure

echo "# Modify by Eric.zhong at 20190904" >> /etc/zabbix/zabbix_server.conf
echo StartSNMPTrapper=1 >> /etc/zabbix/zabbix_server.conf
echo SNMPTrapperFile=/tmp/zabbix_traps.tmp >> /etc/zabbix/zabbix_server.conf
tail -n 10 /etc/zabbix/zabbix_server.conf

systemctl restart  zabbix-server
systemctl restart snmptrapd.service

-- SNMP Trap test
snmptrap -v 1 -c public '.' '' 6 33 '55' . s "eth0"

cat /tmp/zabbix_traps.tmp
16:26:16 2019/09/04 ZBXTRAP
  notificationtype               TRAP
  version                        0
  receivedfrom                   UDP: []:43411->[]:162
  errorstatus                    0
  messageid                      0
  community                      public
  transactionid                  4
  errorindex                     0
  requestid                      0
  DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (55) 0:00:00.55
  SNMPv2-MIB::snmpTrapOID.0      type=6  value=OID: IF-MIB::linkUp.0.33
  IF-MIB::linkUp                 type=4  value=STRING: "eth0"
  SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 type=4  value=STRING: "public"
  SNMPv2-MIB::snmpTrapEnterprise.0 type=6  value=OID: IF-MIB::linkUp

Zabbix monitoring object configuration:
ITEM has two ways:

  • snmptrap[regexp]: Match trap with the regular expression in the monitored item "snmptrap[regexp]", and set the matched trap to the value of the monitored item.
  • snmptrap.fallback: If no matching monitoring item is found and "snmptrap.fallback" monitoring item exists, the trap is set to the value of "snmptrap.fallback".


Monitoring results