DynagenでCCIEを目指す
20100815 RMON
最終更新:
it_certification
-
view
1. 目的
- RMONの設定方法を
2. 構成
2.1. 設定概要
- ルータの初期設定はIPアドレスのみです。
- トップページ/手順書 サーバ系に基づいて、coLinuxがインストールされているものとします。
- トップページ/手順書 サーバ系に基づいて、Linux上でsnmptrapdが起動しているものとします。
- snmptrapは/var/log/messagesに記載されるよう設定されているものとします。
- SNMP version 1を使用します。
- コミュニティ名は「RO_CCIE」とします。
2.2. 構成図

2.3. netファイル
model = 3660 [localhost] [[3660]] image = C:\Program Files\Dynamips\images\c3660-ik9o3s-mz.124-6.T.bin ram = 128 [[ROUTER R1]] f0/0 = NIO_gen_eth:\Device\NPF_{guest OS eth1}
2.4. 初期設定
- R1
! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model ! resource policy ! memory-size iomem 5 ! ! ip cef no ip domain lookup ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 1.1.1.1 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.201.1 255.255.255.0 duplex auto speed auto ! interface FastEthernet0/1 no ip address shutdown duplex auto speed auto ! ip http server no ip http secure-server ! ! ! no cdp run ! ! ! control-plane ! ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
2.5. サーバ側 ルーティング設定
- Guest OS
route add -host 1.1.1.1 gw 192.168.201.1
3. [準備] OID 確認
3.1. 設定投入
ルータのMIB値を取得できるようコミュニティ名を定義します。
R1(config)#snmp-server community RO_CCIE RO
3.2. ping送信
coLinux上からルータR1に対してpingを送信します。この操作を実施しないと「3.3. OID確認」の際に、ifInUcastPktsが取得できません。
[root@localhost ~]# ping 192.168.201.1 PING 192.168.201.1 (192.168.201.1) 56(84) bytes of data. 64 bytes from 192.168.201.1: icmp_seq=1 ttl=255 time=79.9 ms 64 bytes from 192.168.201.1: icmp_seq=2 ttl=255 time=39.9 ms 64 bytes from 192.168.201.1: icmp_seq=3 ttl=255 time=29.9 ms 64 bytes from 192.168.201.1: icmp_seq=4 ttl=255 time=29.9 ms ^C --- 192.168.201.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3339ms rtt min/avg/max/mdev = 29.994/44.992/79.986/20.612 ms [root@localhost ~]#
3.3. OID確認
coLinux上でsnmpwalkコマンドを実行し、取得可能なOIDを確認します。本シナリオでは、検証のやりやすいFa0/0入力方向のパケット数カウンタ ifInUcastPkts.1に着目して検証を進めます。
[root@localhost ~]# snmpwalk -v 1 -c RO_CCIE 192.168.201.1 - 略 - IF-MIB::ifDescr.1 = STRING: FastEthernet0/0 IF-MIB::ifDescr.2 = STRING: FastEthernet0/1 IF-MIB::ifDescr.3 = STRING: Null0 IF-MIB::ifDescr.4 = STRING: Loopback0 - 略 - IF-MIB::ifInUcastPkts.1 = Counter32: 63 <- Fa0/0の入力方向のパケット数カウンタ IF-MIB::ifInUcastPkts.2 = Counter32: 0 IF-MIB::ifInUcastPkts.3 = Counter32: 0 IF-MIB::ifInUcastPkts.4 = Counter32: 0 IF-MIB::ifInNUcastPkts.1 = Counter32: 1 IF-MIB::ifInNUcastPkts.2 = Counter32: 0 IF-MIB::ifInNUcastPkts.3 = Counter32: 0 IF-MIB::ifInNUcastPkts.4 = Counter32: 0 IF-MIB::ifInDiscards.1 = Counter32: 0 IF-MIB::ifInDiscards.2 = Counter32: 0 IF-MIB::ifInDiscards.3 = Counter32: 0 IF-MIB::ifInDiscards.4 = Counter32: 0 IF-MIB::ifInErrors.1 = Counter32: 0 IF-MIB::ifInErrors.2 = Counter32: 0 IF-MIB::ifInErrors.3 = Counter32: 0 IF-MIB::ifInErrors.4 = Counter32: 0
4. [検証] alarm 発生時 trap
4.1. alarm event定義
alarmが発生する条件を定義します。設定の意味は以下の通りです。
項目 | 詳細 |
---|---|
alarm 1 発生 | 20秒間隔で監視し、20秒でifInUcastPktsが20以上増加した場合は、alarm 1を発生させ event 1の動作を実施します&br;一度 event 1が発生したら、以下条件のalarm 1 解除になるまで event 1は発生しません。 |
alarm 1 解除 | 20秒間隔で監視し、20秒でのifInUcastPkts増加量が0以下であった場合は、alarm 1を解除します |
R1(config)#rmon alarm 1 ifInUcastPkts.1 20 delta rising-threshold 20 1 falling-threshold 0 owner "Yamada Taro"
event 1を定義します。最低限コミュニティ名は定義した方が良いと思います。コミュニティ名が未定義ですと、SNMP trapがサーバに届きませんでした。また、何らかの理由でtrapがサーバに届かなかった時に備え、ログに記録する設定「log」も加筆した方が良いと思います。
R1(config)#rmon event 1 trap RO_CCIE log owner "Yamada Hanako"
4.2. その他の設定
SNMP Management Station(SNMPマネージャ)やログ保存の設定を投入します。
R1(config)#snmp-server host 192.168.201.101 traps version 1 RO_CCIE R1(config)#logging buffered 4096
4.3. 設定確認
alarmとeventの設定を確認します。
R1#show rmon alarms Alarm 1 is active, owned by Yamada Taro Monitors ifInUcastPkts.1 every 20 second(s) Taking delta samples, last value was 0 Rising threshold is 20, assigned to event 1 Falling threshold is 0, assigned to event 0 On startup enable rising or falling alarm R1# R1# R1# R1#show rmon events Event 1 is active, owned by Yamada Hanako Description is Event firing causes log and trap to community RO_CCIE, last event fired at 0y0w0d,00:15:46, Current uptime 0y0w0d,00:20:41 Current log entries: index uptime description 1 0y0w0d,00:15:46 R1#
4.4. SNMP trapの確認
Guest OSからルータR1へpingを送信し、RMONによるtrapを発生させます。
[root@localhost ~]# ping 192.168.201.1 PING 192.168.201.1 (192.168.201.1) 56(84) bytes of data. 64 bytes from 192.168.201.1: icmp_seq=1 ttl=255 time=79.9 ms 64 bytes from 192.168.201.1: icmp_seq=2 ttl=255 time=59.9 ms 64 bytes from 192.168.201.1: icmp_seq=3 ttl=255 time=49.9 ms 64 bytes from 192.168.201.1: icmp_seq=4 ttl=255 time=29.9 ms 64 bytes from 192.168.201.1: icmp_seq=5 ttl=255 time=49.9 ms 64 bytes from 192.168.201.1: icmp_seq=6 ttl=255 time=59.9 ms - 略 -
ルータR1でSNMPのデバッグを有効し、trapが送信させる様子を確認します。
R1#debug snmp packets SNMP packet debugging is on R1# R1# *Mar 1 00:28:46.763: %RMON-5-RISINGTRAP: Rising trap is generated because the value of ifInUcastPkts.1 exceeded the rising-threshold value 20 *Mar 1 00:28:46.779: SNMP: Queuing packet to 192.168.201.101 *Mar 1 00:28:46.783: SNMP: V1 Trap, ent rmon, addr 192.168.201.1, gentrap 6, spectrap 1 alarmEntry.1.1 = 1 alarmEntry.3.1 = ifInUcastPkts.1 alarmEntry.4.1 = 2 alarmEntry.5.1 = 20 alarmEntry.7.1 = 20 *Mar 1 00:28:47.031: SNMP: Packet sent via UDP to 192.168.201.101 R1#
Guest OSにSNMP trapが届いた事を確認します。
[root@localhost ~]# tail -f /var/log/messages Aug 15 10:02:54 localhost avahi-daemon[2686]: Server startup complete. Host name is linux.local. Local service cookie is 3107987440. Aug 15 10:02:54 localhost init: quit-plymouth main process (2705) terminated with status 111 Aug 15 10:02:55 localhost avahi-daemon[2686]: Service "linux" (/services/ssh.service) successfully established. Aug 15 10:47:11 localhost ntpd[2652]: synchronized to 210.171.226.40, stratum 1 Aug 15 10:47:11 localhost ntpd[2652]: time reset +2399.896769 s Aug 15 10:47:11 localhost ntpd[2652]: kernel time sync status change 0001 Aug 15 10:53:39 localhost ntpd[2652]: synchronized to 210.171.226.40, stratum 1 Aug 15 11:07:42 localhost ntpd[2652]: synchronized to 130.69.251.23, stratum 1 Aug 15 11:08:08 localhost ntpd[2652]: no servers reachable Aug 15 11:10:08 localhost snmptrapd[2630]: 2010-08-15 11:09:58 192.168.201.1(via UDP: [192.168.201.1]:50279->[192.168.201.101]) TRAP, SNMP v1, community RO_CCIE#012#011SNMPv2-SMI::mib-2.16 Enterprise Specific Trap (1) Uptime: 0:26:46.71#012#011SNMPv2-SMI::mib-2.16.3.1.1.1.1 = INTEGER: 1#011SNMPv2-SMI::mib-2.16.3.1.1.3.1 = OID: IF-MIB::ifInUcastPkts.1#011SNMPv2-SMI::mib-2.16.3.1.1.4.1 = INTEGER: 2#011SNMPv2-SMI::mib-2.16.3.1.1.5.1 = INTEGER: 20#011SNMPv2-SMI::mib-2.16.3.1.1.7.1 = INTEGER: 20 Aug 15 11:12:08 localhost snmptrapd[2630]: 2010-08-15 11:11:58 192.168.201.1(via UDP: [192.168.201.1]:50279->[192.168.201.101]) TRAP, SNMP v1, community RO_CCIE#012#011SNMPv2-SMI::mib-2.16 Enterprise Specific Trap (1) Uptime: 0:28:46.77#012#011SNMPv2-SMI::mib-2.16.3.1.1.1.1 = INTEGER: 1#011SNMPv2-SMI::mib-2.16.3.1.1.3.1 = OID: IF-MIB::ifInUcastPkts.1#011SNMPv2-SMI::mib-2.16.3.1.1.4.1 = INTEGER: 2#011SNMPv2-SMI::mib-2.16.3.1.1.5.1 = INTEGER: 20#011SNMPv2-SMI::mib-2.16.3.1.1.7.1 = INTEGER: 20
5. [検証] alarm 解除時 trap
5.1. alarm event定義
alarmが解除された時にtrapを送信する事もできます。設定の意味は以下の通りです。
項目 | 詳細 |
---|---|
alarm 1 発生 | 20秒間隔で監視し、20秒でifInUcastPktsが20以上増加した場合は、alarm 1を発生させ event 1の動作を実施します&br;一度 event 1が発生したら、以下条件のalarm 1 解除になるまで event 1は発生しません。 |
alarm 1 解除 | 20秒間隔で監視し、20秒でのifInUcastPkts増加量が0以下であった場合は、alarm 1を解除し event 2の動作を実施します |
R1(config)#rmon alarm 1 ifInUcastPkts.1 20 delta rising-threshold 20 1 falling-threshold 0 2 owner "Yamada Taro"
event 2を定義します。
R1(config)#rmon event 2 trap RO_CCIE log owner "Yamada Jiro"
5.2. 設定確認
alarmとeventの設定を確認します。
R1#show rmon alarms Alarm 1 is active, owned by Yamada Taro Monitors ifInUcastPkts.1 every 20 second(s) Taking delta samples, last value was 0 Rising threshold is 20, assigned to event 1 Falling threshold is 0, assigned to event 2 On startup enable rising or falling alarm R1# R1# R1# R1#show rmon events Event 1 is active, owned by Yamada Hanako Description is Event firing causes log and trap to community RO_CCIE, last event fired at 0y0w0d,00:28:46, Current uptime 0y0w0d,00:35:18 Current log entries: index uptime description 1 0y0w0d,00:15:46 2 0y0w0d,00:22:06 3 0y0w0d,00:26:46 4 0y0w0d,00:28:46 Event 2 is active, owned by Yamada Jiro Description is Event firing causes log and trap to community RO_CCIE, last event fired at 0y0w0d,00:32:40, Current uptime 0y0w0d,00:35:18 Current log entries: index uptime description 1 0y0w0d,00:32:40 R1#
5.3. SNMP trapの確認
「4.4. SNMP trapの確認」で発生させ続けているpingを停止させ、alarm解除時のtrapを発生させます。
64 bytes from 192.168.201.1: icmp_seq=113 ttl=255 time=29.9 ms 64 bytes from 192.168.201.1: icmp_seq=114 ttl=255 time=29.9 ms ^C --- 192.168.201.1 ping statistics --- 114 packets transmitted, 114 received, 0% packet loss, time 116592ms rtt min/avg/max/mdev = 9.999/47.185/99.985/18.894 ms [root@localhost ~]#
ルータR1のデバッグメッセージからtrapが送信された事を確認します。
R1(config)# *Mar 1 00:32:40.579: %RMON-5-FALLINGTRAP: Falling trap is generated because the value of ifInUcastPkts.1 has fallen below the falling-threshold value 0 *Mar 1 00:32:40.583: SNMP: Queuing packet to 192.168.201.101 *Mar 1 00:32:40.587: SNMP: V1 Trap, ent rmon, addr 192.168.201.1, gentrap 6, spectrap 2 alarmEntry.1.1 = 1 alarmEntry.3.1 = ifInUcastPkts.1 alarmEntry.4.1 = 2 alarmEntry.5.1 = 0 alarmEntry.8.1 = 0 *Mar 1 00:32:40.835: SNMP: Packet sent via UDP to 192.168.201.101 R1(config)#
Guest OSにSNMP trapが届いた事を確認します。
[root@localhost ~]# tail -f /var/log/messages Aug 15 10:47:11 localhost ntpd[2652]: time reset +2399.896769 s Aug 15 10:47:11 localhost ntpd[2652]: kernel time sync status change 0001 Aug 15 10:53:39 localhost ntpd[2652]: synchronized to 210.171.226.40, stratum 1 Aug 15 11:07:28 localhost snmptrapd[2630]: 2010-08-15 11:07:18 192.168.201.1(via UDP: [192.168.201.1]:50279->[192.168.201.101]) TRAP, SNMP v1, community RO_CCIE#012#011SNMPv2-SMI::mib-2.16 Enterprise Specific Trap (1) Uptime: 0:22:06.62#012#011SNMPv2-SMI::mib-2.16.3.1.1.1.1 = INTEGER: 1#011SNMPv2-SMI::mib-2.16.3.1.1.3.1 = OID: IF-MIB::ifInUcastPkts.1#011SNMPv2-SMI::mib-2.16.3.1.1.4.1 = INTEGER: 2#011SNMPv2-SMI::mib-2.16.3.1.1.5.1 = INTEGER: 20#011SNMPv2-SMI::mib-2.16.3.1.1.7.1 = INTEGER: 20 Aug 15 11:07:42 localhost ntpd[2652]: synchronized to 130.69.251.23, stratum 1 Aug 15 11:08:08 localhost ntpd[2652]: no servers reachable Aug 15 11:09:57 localhost snmptrapd[2630]: 2010-08-15 11:09:47 192.168.201.1(via UDP: [192.168.201.1]:50279->[192.168.201.101]) TRAP, SNMP v1, community RO_CCIE#012#011SNMPv2-SMI::enterprises.9.9.43.2 Enterprise Specific Trap (1) Uptime: 0:26:35.17#012#011SNMPv2-SMI::enterprises.9.9.43.1.1.6.1.3.8 = INTEGER: 1#011SNMPv2-SMI::enterprises.9.9.43.1.1.6.1.4.8 = INTEGER: 2#011SNMPv2-SMI::enterprises.9.9.43.1.1.6.1.5.8 = INTEGER: 3 Aug 15 11:10:08 localhost snmptrapd[2630]: 2010-08-15 11:09:58 192.168.201.1(via UDP: [192.168.201.1]:50279->[192.168.201.101]) TRAP, SNMP v1, community RO_CCIE#012#011SNMPv2-SMI::mib-2.16 Enterprise Specific Trap (1) Uptime: 0:26:46.71#012#011SNMPv2-SMI::mib-2.16.3.1.1.1.1 = INTEGER: 1#011SNMPv2-SMI::mib-2.16.3.1.1.3.1 = OID: IF-MIB::ifInUcastPkts.1#011SNMPv2-SMI::mib-2.16.3.1.1.4.1 = INTEGER: 2#011SNMPv2-SMI::mib-2.16.3.1.1.5.1 = INTEGER: 20#011SNMPv2-SMI::mib-2.16.3.1.1.7.1 = INTEGER: 20 Aug 15 11:12:08 localhost snmptrapd[2630]: 2010-08-15 11:11:58 192.168.201.1(via UDP: [192.168.201.1]:50279->[192.168.201.101]) TRAP, SNMP v1, community RO_CCIE#012#011SNMPv2-SMI::mib-2.16 Enterprise Specific Trap (1) Uptime: 0:28:46.77#012#011SNMPv2-SMI::mib-2.16.3.1.1.1.1 = INTEGER: 1#011SNMPv2-SMI::mib-2.16.3.1.1.3.1 = OID: IF-MIB::ifInUcastPkts.1#011SNMPv2-SMI::mib-2.16.3.1.1.4.1 = INTEGER: 2#011SNMPv2-SMI::mib-2.16.3.1.1.5.1 = INTEGER: 20#011SNMPv2-SMI::mib-2.16.3.1.1.7.1 = INTEGER: 20 Aug 15 11:15:52 localhost snmptrapd[2630]: 2010-08-15 11:15:52 192.168.201.1(via UDP: [192.168.201.1]:50279->[192.168.201.101]) TRAP, SNMP v1, community RO_CCIE#012#011SNMPv2-SMI::mib-2.16 Enterprise Specific Trap (2) Uptime: 0:32:40.58#012#011SNMPv2-SMI::mib-2.16.3.1.1.1.1 = INTEGER: 1#011SNMPv2-SMI::mib-2.16.3.1.1.3.1 = OID: IF-MIB::ifInUcastPkts.1#011SNMPv2-SMI::mib-2.16.3.1.1.4.1 = INTEGER: 2#011SNMPv2-SMI::mib-2.16.3.1.1.5.1 = INTEGER: 0#011SNMPv2-SMI::mib-2.16.3.1.1.8.1 = INTEGER: 0
添付ファイル