[Zabbix] SNMP TRAP 监控
1、安装关联包
# yum install -y net-snmp-utils net-snmp-perl net-snmp
2、下载zabbix-3.2.4 tar包
# cd /usr/local/src/
# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.4/zabbix-3.2.4.tar.gz
# tar -zxvfzabbix-3.2.4.tar.gz
3、配置
# cp -a/usr/local/src/zabbix-3.2.4/misc/snmptrap/zabbix_trap_receiver.pl /usr/bin/
#chmod +x /usr/bin/zabbix_trap_receiver.pl
# vi /etc/snmp/snmptrapd.conf
disableAuthorization yes #不需要团体名 perl do "/usr/bin/zabbix_trap_receiver.pl"; |
# vi /etc/zabbix/zabbix_server.conf #或者编辑zabbix_proxy.conf
StartSNMPTrapper=1
SNMPTrapperFile=/tmp/zabbix_traps.tmp
#该目录必须与zabbix_trap_receiver.pl脚本中定义一致
# systemctl restart zabbix-server
4、导入mib库
将mib库文件复制至 /usr/share/snmp/mibs 目录中并新建与配置 /etc/snmp/snmp.conf 文件。
mibs +JUNIPER-MIB:JUNIPER-FABRIC-CHASSIS:BGP4-MIB
5、重启 snmptrapd 生效
#systemctl enable snmptrapd
#systemctl restart snmptrapd
# netstat -tunlp |grep 162
udp 0 0 0.0.0.0:162 0.0.0.0:* 4620/snmptrapd
6、配置snmptrap 存档
# mkdir -p /var/log/zabbix_traps_archive
# vi /etc/logrotate.d/zabbix_traps
/tmp/zabbix_traps.tmp
{ olddir /var/log/zabbix_traps_archive } |
7、测试
# snmptrap -v 1 -c public 127.0.0.1 '.1.3.6.1.6.3.1.1.5.4' '0.0.0.0' 633 '55' .1.3.6.1.6.3.1.1.5.4 s "eno16780032"
# more /tmp/zabbix_traps.tmp
16:12:20 2017/03/21 ZBXTRAP 127.0.0.1 PDU INFO: notificationtype TRAP version 0 receivedfrom UDP: [127.0.0.1]:42462->[127.0.0.1]:162 errorstatus 0 messageid 0 community public transactionid 1 errorindex 0 requestid 0 VARBINDS: 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: "eno16780032" SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 type=4 value=STRING: "public" SNMPv2-MIB::snmpTrapEnterprise.0 type=6 value=OID: IF-MIB::linkUp |
8、配置zabbix web端
①新建模板 "TemplateSNMP trap fallback"
新建监控项:
Name: SNMP trap fallback
Type: SNMP trap
Key: snmptrap.fallback
Type of information: Log
②新建模板“Template SNMP traps” 并链接至模板“Template SNMP trap fallback”
新建监控项: snmptrap test
新建触发器