溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap

發(fā)布時間:2020-05-29 04:24:45 來源:網(wǎng)絡 閱讀:782 作者:airya 欄目:系統(tǒng)運維

SNMP Trpe可以主動發(fā)信息推送給zabbix-server

前提配置條件
zabbix server端:

1.需要支持SNMP,編譯安裝時--with-net-snmp
2.zabbix server 配置StartSNMPTrapper和SNMPTrapperFile
3.配置SNMPTT服務
4.配置Perl trap receiver
5.允許161,162端口udp通信

被監(jiān)控設備:

1.配置SNMP Trap信息發(fā)送
2.允許zabbix server和被監(jiān)控設備的161,162端口udp通信

數(shù)據(jù)收集流程

被監(jiān)控設備觸發(fā)事件 >>>(通過162端口)>>> SNMPTrapd(trap服務) >>> SNMPTT(進行格式化處理)>>>(寫入對應的日志文件)>>> SNMP Trapper File <<< zabbix server (Trap進程)讀取信息。并和對應的監(jiān)控設備進行匹配,如果有告警規(guī)則就會觸發(fā)告警

語法

snmptrap[regexp] 獲取匹配正則表達式指定的trap信息,如果正則沒有指定,就匹配所有Trap信息
snmptrap.fallback 獲取未被上個監(jiān)控項。所匹配其他所有的Trap信息

zabbix-server 配置
安裝snmp trap 服務
yum -y install net-snmp net-snmp-utils net-snmp-perl

下載zabbix官方提供的zabbix_trap_receiver腳本,并移動到/usr/bin目錄下
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.6/zabbix-4.2.6.tar.gz
 tar -zxvf zabbix-4.2.6.tar.gz
cd zabbix-4.2.6
cp misc/snmptrap/zabbix_trap_receiver.pl /usr/bin/
chmod a+x /usr/bin/zabbix_trap_receiver.pl 
配置snmp trap 服務
vim /etc/snmp/snmptrapd.conf 
加入
authCommunity log,execute,net public
perl do "/usr/bin/zabbix_trap_receiver.pl"

重啟snmptrap服務
systemctl restart snmptrapd.service
systemctl enable snmptrapd.service

更改zabbix server配置
vim /etc/zabbix/zabbix_server.conf
SNMPTrapperFile=/tmp/zabbix_traps.tmp
StartSNMPTrapper=1
重啟服務
systemctl restart zabbix-server
被監(jiān)控端配置

由于沒有網(wǎng)絡設備,在linux端安裝snmp命令演示

yum -y install net-snmp-utils

測試是否能在被監(jiān)控端發(fā)送信息到snmptrap服務端

snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test"

在服務端查看/tmp/zabbix_traps.tmp文件是否有寫入數(shù)據(jù)

more /tmp/zabbix_traps.tmp 
00:53:36 2019/09/10 ZBXTRAP 192.168.146.134
PDU INFO:
  notificationtype               TRAP
  version                        1
  receivedfrom                   UDP: [192.168.146.134]:51439->[192.168.146.133]:162
  errorstatus                    0
  messageid                      0
  community                      public
  transactionid                  1
  errorindex                     0
  requestid                      199074524
VARBINDS:
  SNMPv2-MIB::snmpTrapOID.0      type=6  value=OID: SNMPv2-SMI::org.4.1.4.1.47
  SNMPv2-MIB::sysName.0          type=4  value=STRING: "SNMP Trap Test"
登錄zabbix web界面創(chuàng)建SNMPTrap監(jiān)控項

【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap
【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap

在被監(jiān)控端寫入信息到服務端
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test"
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test"
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test"
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test"
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test"
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test"
最新數(shù)據(jù)已獲取到數(shù)據(jù)

【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap
【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap

在被監(jiān)控端,寫入正則表達式所匹配的信息
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test linuxcs"
[root@localhost ~]# snmptrap -v 2c -c public 192.168.146.133 "snmptraptest" '1.3.4.1.4.1.47' SNMPv2-MIB::sysName.0 s "SNMP Trap Test linuxcs"
已經(jīng)獲取到數(shù)據(jù)

【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap
【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap

歡迎關注公眾號。一起交流,學習

【Zabbix4.2學習筆記】6、數(shù)據(jù)收集-SNMP Trap

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI