trap を受信できればいいので、ちょーシンプル。
# cat /etc/snmp/snmpdtrapd.conf
authCommunity log,execute,net test
コミュニティ test からの trap を受け付ける。
action として、ログ、コマンドの実行、別ネットワークへの転送を許可。
[ 動作確認 ]
# snmptrapd -f -P -M /usr/share/snmp/mibs -m ALL -c /etc/snmp/snmpdtrapd.conf -Of
Warning: -P option is deprecated; use -f -Le instead
NET-SNMP version 5.3.2.2
-P オプション(ログメッセージを標準エラーに表示する)は deprecated ..
-P を -Le にして起動
# snmptrapd -f -Le -M /usr/share/snmp/mibs -m ALL -c /etc/snmp/snmpdtrapd.conf -Of
NET-SNMP version 5.3.2.2
ネットワーク機器のリンクをdown -> up させてトラップを発砲。
# snmptrapd -f -Le -M /usr/share/snmp/mibs -m ALL -c /etc/snmp/snmpdtrapd.conf -Of
NET-SNMP version 5.3.2.2
2010-04-07 20:09:53 172.20.90.165(via UDP: [172.20.90.165]:1024) TRAP, SNMP v1, community test
.iso.org.dod.internet.private.enterprises.cisco.ciscoMgmt.arrowPoint.apProducts.css11501 Link Down Trap (0) Uptime: 0:33:54.88
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex.7 = INTEGER: 7 .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifAdminStatus.7 = INTEGER: down(2) .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifOperStatus.7 = INTEGER: down(2)
2010-04-07 20:09:57 172.20.90.165(via UDP: [172.20.90.165]:1024) TRAP, SNMP v1, community test
.iso.org.dod.internet.private.enterprises.cisco.ciscoMgmt.arrowPoint.apProducts.css11501 Link Up Trap (0) Uptime: 0:33:58.16
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex.7 = INTEGER: 7 .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifAdminStatus.7 = INTEGER: up(1) .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifOperStatus.7 = INTEGER: up(1)
- OID 表示 ( -Of -> -On に変更 )
# snmptrapd -f -Le -M /usr/share/snmp/mibs -m ALL -c /etc/snmp/snmpdtrapd.conf -On
NET-SNMP version 5.3.2.2
2010-04-07 20:12:52 172.20.90.165(via UDP: [172.20.90.165]:1024) TRAP, SNMP v1, community test
.1.3.6.1.4.1.9.9.368.4.7 Link Down Trap (0) Uptime: 0:36:53.01
.1.3.6.1.2.1.2.2.1.1.7 = INTEGER: 7 .1.3.6.1.2.1.2.2.1.7.7 = INTEGER: down(2) .1.3.6.1.2.1.2.2.1.8.7 = INTEGER: down(2)
2010-04-07 20:12:54 172.20.90.165(via UDP: [172.20.90.165]:1024) TRAP, SNMP v1, community test
.1.3.6.1.4.1.9.9.368.4.7 Link Up Trap (0) Uptime: 0:36:55.16
.1.3.6.1.2.1.2.2.1.1.7 = INTEGER: 7 .1.3.6.1.2.1.2.2.1.7.7 = INTEGER: up(1) .1.3.6.1.2.1.2.2.1.8.7 = INTEGER: up(1)
- capture data
リンクダウン
Simple Network Management Protocol
version: version-1 (0)
community: test
data: trap (4)
trap
enterprise: 1.3.6.1.4.1.9.9.368.4.7 (SNMPv2-SMI::enterprises.9.9.368.4.7)
agent-addr: 172.20.90.165 (172.20.90.165)
generic-trap: linkDown (2)
specific-trap: 0
time-stamp: 228025
variable-bindings: 3 items
IF-MIB::ifIndex.7 (1.3.6.1.2.1.2.2.1.1.7): 7
Object Name: 1.3.6.1.2.1.2.2.1.1.7 (IF-MIB::ifIndex.7)
IF-MIB::ifEntry.ifIndex: 7
IF-MIB::ifIndex: 7
IF-MIB::ifAdminStatus.7 (1.3.6.1.2.1.2.2.1.7.7): down (2)
Object Name: 1.3.6.1.2.1.2.2.1.7.7 (IF-MIB::ifAdminStatus.7)
IF-MIB::ifEntry.ifIndex: 7
IF-MIB::ifAdminStatus: down (2)
IF-MIB::ifOperStatus.7 (1.3.6.1.2.1.2.2.1.8.7): down (2)
Object Name: 1.3.6.1.2.1.2.2.1.8.7 (IF-MIB::ifOperStatus.7)
IF-MIB::ifEntry.ifIndex: 7
IF-MIB::ifOperStatus: down (2)
リンクアップ
Simple Network Management Protocol
version: version-1 (0)
community: test
data: trap (4)
trap
enterprise: 1.3.6.1.4.1.9.9.368.4.7 (SNMPv2-SMI::enterprises.9.9.368.4.7)
agent-addr: 172.20.90.165 (172.20.90.165)
generic-trap: linkUp (3)
specific-trap: 0
time-stamp: 228536
variable-bindings: 3 items
IF-MIB::ifIndex.7 (1.3.6.1.2.1.2.2.1.1.7): 7
Object Name: 1.3.6.1.2.1.2.2.1.1.7 (IF-MIB::ifIndex.7)
IF-MIB::ifEntry.ifIndex: 7
IF-MIB::ifIndex: 7
IF-MIB::ifAdminStatus.7 (1.3.6.1.2.1.2.2.1.7.7): up (1)
Object Name: 1.3.6.1.2.1.2.2.1.7.7 (IF-MIB::ifAdminStatus.7)
IF-MIB::ifEntry.ifIndex: 7
IF-MIB::ifAdminStatus: up (1)
IF-MIB::ifOperStatus.7 (1.3.6.1.2.1.2.2.1.8.7): up (1)
Object Name: 1.3.6.1.2.1.2.2.1.8.7 (IF-MIB::ifOperStatus.7)
IF-MIB::ifEntry.ifIndex: 7
IF-MIB::ifOperStatus: up (1)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.