Zabbix中snmp-traps的设置
创始人
2024-07-24 15:01:26
0

  zabbixsnmp-traps设置

  工作方式

  1.   (SNMP Trap) -> snmptrapd -> snmptrap.sh -> zabbix_sender -> (Zabbix)  
  2.  

  在/etc/snmp/snmptrapd.conf文件添加

  1.   traphandle default /bin/bash /path/to/zabbix/bin/snmptrap.sh  
  2.  

  启动snmptrapd服务:

  1.   snmptrapd -C -c /etc/snmp/snmptrapd.conf -Lf /var/log/net-snmptrap.log  
  2.  

  修改/path/to/zabbix/bin/snmptrap.sh. 如果不正确的话,坚持zabbix 树,复制到zabbix/bin下.:

  1.   ZABBIX_SERVER="zabbix-host"; # hostname of zabbix server  
  2.  
  3.   ZABBIX_PORT="nnnn"; # nnnn=same as 'Listen Port' in zabbix_server.conf  
  4.  
  5.   ZABBIX_SENDER="/path/to/zabbix/bin/zabbix_sender"; # insert you path  
  6.  
  1.   #According to the snmpdtrapd.conf man page, these  
  2.  
  3.   # fields should be received in the following order:  
  4.  
  1.   # there may be several more payload fields, but one is all I need.  
  2.  
  3.   # read more if it suits you.  
  4.  
  5.   hostname=`echo $hostname|cut -f1 -d'.'` # trim off the fluff  
  6.  
  7.   trapoid=`echo $trapoid|cut -f3 -d' '` # ditto  
  8.  
  9.   # I don't need uptime or ip right now ...  
  10.  
  11.   payload=`echo $payload1|cut -f3- -d' '` # ditto ditto  
  12.  
  13.   ### This section records all traps under a 'dummy' host in zabbix, for debugging  
  14.  
  15.   ### Delete if you don't need to do this.  
  16.  
  17.   ### I use it to verify the OID of traps before using them as keys on specific hosts  
  18.  
  19.   # create a string to send to zabbix.  
  20.  
  21.   str="HOST=$hostname TRAP OID=$trapoid PAYLOAD=$payload" 
  22.  
  23.   # now set the key and host name for zabbix  
  24.  
  25.   KEY="alltraps";  
  26.  
  27.   HOST="trapperjohn";  
  28.  
  29.   #now call the zabbix_sender program with all parameters.  
  30.  
  31.   $ZABBIX_SENDER $ZABBIX_SERVER $ZABBIX_PORT $HOST $KEY "$str"  
  32.  
  33.   ### End dummy host section  
  34.  
  35.   ### This section records traps for specific for specific hosts.  
  36.  
  37.   ### Edit as needed for you situation.  
  38.  
  39.   KEY="$trapoid";  
  40.  
  41.   HOST="$hostname";  
  42.  
  43.   str="$payload";  
  44.  
  45.   $ZABBIX_SENDER $ZABBIX_SERVER $ZABBIX_PORT $HOST $KEY "$str"  
  46.  

  调试可:

  1.   echo $ZABBIX_SENDER $ZABBIX_SERVER $ZABBIX_PORT $HOST:$KEY "$str" > /tmp/testtrap.txt  
  2.  

  测试:

  1.   snmptrap -v1 -cpublic localhost .1.3.6.1.6.3.1.1.5.2 0 0 "" "" .1.3.6.1.4.1 s "aaa"  
  2.  

  在zabbix服务器端:

  1. Added host:

  1.   name=snmpTraps 
  2.  
  3.   ip address = (didn't enter an ip address)  
  4.  
  5.   port = 10005 (port which zabbix server is on) - do i need to set this to 162?  
  6.  
  7.   Set status to monitored....didn't add anything else eg IP address, group etc  
  8.  

  2. Added item to host (i.e to snmpTraps)

  1.   key=snmpTraps 
  2.  
  3.   type=zabbix trapper  
  4.  
  5.   type of info=numeric 
  6.  
  7.   store value=As is  
  8.  
  9.   Allowed host= (i have left this line blank)  
  10.  

  Zabbix中snmp-traps的设置完成。

【编辑推荐】

Zabbix批量添加主机

Zabbix下数据库升级

Zabbix代理安装介绍

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...