これは通常は不要。snmptrapを受けてzabbixで何かしたい場合の設定(?)
★ダウンロード
# wget http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-sender-2.0.5-1.el6.x86_64.rpm
★インストール(2013.06.21 時点のバージョンは 2.0.6-1)
# rpm -ivh zabbix-sender-2.0.5-1.el6.x86_64.rpm
★インストール内容確認
# rpm -qs zabbix-sender
通常 /usr/bin/zabbix_sender
通常 /usr/share/man/man1/zabbix_sender.1.gz
★コマンドパス確認
# which zabbix_sender
/usr/bin/zabbix_sender
★snmptrapd設定(設定例)
# vi /etc/snmp/snmptrapd.conf
---------------------------------------------------------------
# Example configuration file for snmptrapd
#
# No traps are handled by default, you must edit this file!
#
# authCommunity log,execute,net public
# traphandle SNMPv2-MIB::coldStart /usr/bin/bin/my_great_script cold
authCommunity log,execute,net private
authCommunity log,execute,net public
traphandle default /bin/bash /etc/zabbix/snmptrap.sh
---------------------------------------------------------------
★シェルスクリプト設定
# vi /etc/zabbix/snmptrap.sh(設定例)
---------------------------------------------------------------
#!/bin/bash
# CONFIGURATION
ZABBIX_SERVER="127.0.0.1";
ZABBIX_PORT="10051";
ZABBIX_SENDER="/usr/bin/zabbix_sender";
KEY="snmptraps";
HOST="snmptraps";
# Execute
read hostname
read ip
read uptime
read oid
read address
read community
read enterprise
oid=`echo $oid|cut -f2 -d' '`
address=`echo $address|cut -f2 -d' '`
community=`echo $community|cut -f2 -d' '`
enterprise=`echo $enterprise|cut -f2 -d' '`
oid=`echo $oid|cut -f11 -d'.'`
community=`echo $community|cut -f2 -d'"'`
str="$hostname $address $community $enterprise $oid"
# Output
$ZABBIX_SENDER -z $ZABBIX_SERVER -vv -p $ZABBIX_PORT -s $HOST -k $KEY -o "$str"
# Debug
echo $str >> /tmp/snmptrap.log
---------------------------------------------------------------
★snmptrapdの起動
# service snmptrapd start
★snmptrapdの自動起動設定
# chkconfig snmptrapd on
★ファイアウォールの UDP 162ポート解放
# vi /etc/sysconfig/iptables
【-A INPUT -m state --state NEW -m udp -p udp --dport 162 -j ACCEPT】
# service iptables restart
これでtrapを受けると/var/log/messageにそのログが出力されているハズ。
あとはzabbixのWebでうまく設定すればなんとかなる?!(まだそこまでできていない)
関連リンク:zabbix-agent2.0のインストール(監視対象サーバー用)
関連リンク:trap受信からのzabbix_senderの実行がうまく動作しない