Wednesday, June 20, 2007

[Cisco] Event Manager ไว้ต้องการจับ event แล้วให้ทำคำสั่ง

Event Manager:
เวลาเราต้องการให้ router พบ event บางอย่างแล้วให้ action ตาม command ที่กำหนด ตัวอย่างคือ เมื่อ event manager พบ syslog ที่มี pattern neighbor x.x.x.x Up/Down แล้วให้ทำคำสั่ง

#conf t
event manager applet bgp-down
event syslog pattern "neighbor 192.168.10.2 Down" <-- ตรวจจับ event ของ syslog ที่มี pattern "neighbor 192.168.10.2 Down"
action 1.0 cli command "conf t" <--- ให้เริ่มทำคำสั่ง
action 1.1 cli command "int f0/0"
action 1.2 cli command "no ip policy route-map redirect"
action 1.3 cli command "no ip wccp 80 redirect in"
action 1.4 syslog msg "Alert !!!! policy change by BGP-Down" <--- ให้ส่ง message ไป syslog
action 1.5 mail server "20.20.20.1" to "kitti@mail.xx" from "event-mager@router" subject "Alert neighbor BGP down" body "Neighbor 192.168.10.2 Down" <--- ให้ส่ง mail ด้วย

event manager applet bgp-up
event syslog pattern "neighbor 192.168.10.2 Up"
action 1.0 cli command "conf t"
action 1.1 cli command "int f0/0"
action 1.2 cli command "ip policy route-map redirect"
action 1.3 cli command "ip wccp 80 redirect in
action 1.4 syslog msg "Alert !!! Policy change by BGP-Up"
action 1.5 mail server "20.20.20.1" to "kitti@mail.xx" from "event-mager@router" subject "Alert neighbor BGP up" body "Neighbor 192.168.10.2 Up"