ܼ

1. snmptrapd

snmptrapdΥ󥹥ȡϳ䰦
snmptrapd.confˤsnmptrapd˥Ĥ륳ߥ˥ƥ̾ZABBIXSNMPTrapƤ륹ץȤؤϢԤ

  • authCommunity [Options] [CommunityID]
    SNMPTrap륳ߥ˥ƥ̾ȵĤ륢ꤹ롣
    ʣꤹʣԵܤ롣
    [Options]Ǥϰʲιܤꤹ롣
    logsyslogstdoutؤΥեϤ
    executeץμ¹Ԥ
    net̤žġʥ᡼ž
  • traphandle default [SCRIPT NAME]
    ZABBIX°SNMPTrapϢѥץ(snmptrap.sh)ꤹ롣
    ѥϥ󥹥ȡ˽सͤѹ롣
  • snmptrapd.conf
    authCommunity log,execute,net private
    authCommunity log,execute,net public
    traphandle default /bin/bash /usr/local/zabbix/sbin/snmptrap.sh

ʾԤsnmptrapdƵư롣

2. ZABBIX

ZABBIX¦SNMPTrapϢѥץ(snmptrap.sh)ͳϢȤԤ
°snmptrap.shϴĶ˹碌ơʲβս롣

  • /usr/local/zabbix/sbin/snmptrap.sh
    # CONFIGURATION
    ZABBIX_SERVER="{IP Address}";
    ZABBIX_PORT="10051";
    ZABBIX_SENDER="/usr/local/zabbix/sbin/zabbix_sender";
    KEY="snmptraps";
    HOST="snmptraps";

СˤäƤưʤ礬롣
λäϢȥץȤФƸҤνԤ

3. ƥ

WebUI夫饢ƥԤ

4. ȥꥬ

WebUI夫ȥꥬԤ

  • 1
    Trapˡpower-onפʸ󤬴ޤޤ祢顼
    {{HOSTNAME}:snmptraps.str(power-on)}=1
  • 1ְTrapTrapˡsnmptrapsפʸ󤬴ޤޤƤʤ祢顼
    ({HOSTNAME}:snmptraps. nodata( 3600 ) }=0)&({HOSTNAME}:snmptraps. str( snmptraps,3600 ) }=0)
  • 24ְTrapTrapˡpower-onפʸ󤬴ޤޤ祢顼
    {{HOSTNAME}:snmptraps.nodata(86400)}=0)&{{HOSTNAME}:snmptraps.str(power-on,86400)}=1)

5. ƥ

SNMPTrapݤˤ/var/log/messages˾󤫵ܤ롣

  • ˼ǤƤ
    ˼ǤƤϰʲͤʥϤ롣
    snmptrapd[11095]: 2009-04-03 00:51:13 192.168.1.249(via UDP: [192.168.1.249]:1712) TRAP, SNMP v1, community public     SNMPv2-SMI::zeroDotZero Link Up Trap (0) Uptime: 67 days, 4:54:21.00    IF-MIB::ifIndex.7 = INTEGER: 7

  • ߥ˥ƥ̾ߥʤɤǥݤƤϰʲΥϤ롣
    snmptrapd[10744]: No access configuration - dropping trap.
  • ԤƤ
    /var/log/messagesƱͤƤΥ«ͤ뤳Ȥǥ򰵽̤뵡ǽ뤿ᡢSNMPTrapμ˷֤ԤȰʲͤʥǤ
    last message repeated 3 times

snmptrap.shưʤб

֤ΥץȤ˵ǽʤὤäɬפ롣

#!/bin/bash

# CONFIGURATION
ZABBIX_SERVER="127.0.0.1";
ZABBIX_PORT="10051";
ZABBIX_SENDER="/usr/local/zabbix/sbin/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 -p $ZABBIX_PORT -s $HOST -k $KEY -o "$str"

# Debug
echo $str > /tmp/snmptrap.log

ȥå   Խ ʬ ʎގ̎ ź ʣ ̾ѹ   ǽ   إ   ǽRSS
Last-modified: 2009-11-25 () 10:58:33 (3951d)