zabbix中snmp-traps设置

上一篇 / 下一篇  2007-05-16 00:00:00 / 个人分类:系统监控

参考文章,摸索了5天吧,终于搞清楚了,呵呵。

It works something like this:

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

Basically, the point of snmptrap.sh is to translate a SNMP trap into a Zabbix trap


在/etc/snmp/snmptrapd.conf文件添加
traphandle default /bin/bash /path/to/zabbix/bin/snmptrap.sh
启动snmptrapd服务:

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

Now edit /path/to/zabbix/bin/snmptrap.sh. If not found, check the zabbix source tree, and

copy it to the zabbix/bin directory. For my application the following lines work great:

####### Begin snmptrap.sh #########

## GENERAL CONFIGURATION
ZABBIX_SERVER="zabbix-host"; # hostname of zabbix server
ZABBIX_PORT="nnnn"; # nnnn=same as 'Listen Port' in zabbix_server.conf
ZABBIX_SENDER="/path/to/zabbix/bin/zabbix_sender"; # insert you path
## END OF GENERAL CONFIGURATION

#According to the snmpdtrapd.conf man page, these
# fields should be received in the following order:

read hostname
read ip
read uptime
read trapoid
read payload
# there may be several more payload fields, but one is all I need.
# read more if it suits you.

hostname=`echo $hostname|cut -f1 -d'.'` # trim off the fluff
trapoid=`echo $trapoid|cut -f3 -d' '` # ditto

# I don't need uptime or ip right now ...

payload=`echo $payload1|cut -f3- -d' '` # ditto ditto


### This section records all traps under a 'dummy' host in zabbix, for debugging
### Delete if you don't need to do this.
### I use it to verify the OID of traps before using them as keys on specific hosts

# create a string to send to zabbix.
str="HOST=$hostname TRAP OID=$trapoid PAYLOAD=$payload"

# now set the key and host name for zabbix
KEY="alltraps";
HOST="trapperjohn";

#now call the zabbix_sender program with all parameters.
$ZABBIX_SENDER $ZABBIX_SERVER $ZABBIX_PORT $HOST $KEY "$str"

### End dummy host section


### This section records traps for specific for specific hosts.
### Edit as needed for you situation.

KEY="$trapoid";
HOST="$hostname";
str="$payload";
$ZABBIX_SENDER $ZABBIX_SERVER $ZABBIX_PORT $HOST $KEY "$str"

######### End snmptrap.sh ###########

调试可:

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

测试:

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

在zabbix服务器端:

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

2. Added item to host (i.e to snmpTraps)
key=snmpTraps
type=zabbix trapper
type of info=numeric
store value=As is
Allowed host= (i have left this line blank)


TAG:

引用 删除 winnie   /   2008-07-03 20:00:33
关于探讨SNMPTRAP方面的东西 如果方便请+QQ:44902588 敲门砖SNMP
引用 删除 Guest   /   2008-07-03 19:59:26
有些问题想请教你
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-11-23  
      1
2345678
9101112131415
16171819202122
23242526272829
30      

我的存档

数据统计

  • 访问量: 3549
  • 日志数: 538
  • 建立时间: 2008-01-09
  • 更新时间: 2008-01-09

RSS订阅

Open Toolbar