zabbix中snmp-traps設定解析(1)

來源:互聯網
上載者:User

zabbix中snmp-traps設定解析如下:

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 ###########


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.