=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2009.10.27 16:36:15 =~=~=~=~=~=~=~=~=~=~=~= Oct 27 16:36:34.896: %BGP-5-ADJCHANGE: neighbor 64.124.97.202 Down Neighbor deleted Oct 27 16:36:41.976: %BGP-5-ADJCHANGE: neighbor 64.124.97.203 Down Neighbor deleted Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: while executing Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if { $states($n) == "Up" } { Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ("foreach" body line 2) Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "foreach n $neighbors { Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: if { $states($n) == "Up" } { Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: } Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "$slave eval $Contents" Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (procedure "eval_script" line 7) Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "eval_script slave $scriptname" Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if {$security_level == 1} { #untrusted script Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp create -safe slave Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdin slave Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdout slave Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ..." Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (file "tmpsys:/lib/tcl/base.tcl" line 50) Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: Tcl policy execute failed: Oct 27 16:36:42.188: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:36:50.464: %BGP-5-ADJCHANGE: neighbor 64.124.97.210 Down Neighbor deleted Oct 27 16:36:57.184: %BGP-5-ADJCHANGE: neighbor 64.124.97.211 Down Neighbor deleted Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: while executing Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if { $states($n) == "Up" } { Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ("foreach" body line 2) Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "foreach n $neighbors { Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: if { $states($n) == "Up" } { Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: } Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "$slave eval $Contents" Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (procedure "eval_script" line 7) Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "eval_script slave $scriptname" Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if {$security_level == 1} { #untrusted script Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp create -safe slave Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdin slave Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdout slave Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ..." Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (file "tmpsys:/lib/tcl/base.tcl" line 50) Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: Tcl policy execute failed: Oct 27 16:36:57.392: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:36:58.960: %TRACKING-5-STATE: 100 ip route 0.0.0.0/0 reachability Up->Down Oct 27 16:38:04.476: %BGP-5-ADJCHANGE: neighbor 64.124.97.210 Up Oct 27 16:38:04.564: %BGP-5-ADJCHANGE: neighbor 64.124.97.203 Up Oct 27 16:38:04.908: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: while executing Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if { $states($n) == "Up" } { Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ("foreach" body line 2) Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "foreach n $neighbors { Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: if { $states($n) == "Up" } { Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: } Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "$slave eval $Contents" Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (procedure "eval_script" line 7) Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "eval_script slave $scriptname" Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if {$security_level == 1} { #untrusted script Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp create -safe slave Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdin slave Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdout slave Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ..." Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (file "tmpsys:/lib/tcl/base.tcl" line 50) Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: Tcl policy execute failed: Oct 27 16:38:04.912: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:38:05.592: %BGP-5-ADJCHANGE: neighbor 64.124.97.202 Up Oct 27 16:38:05.616: %BGP-5-ADJCHANGE: neighbor 64.124.97.211 Up Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: while executing Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if { $states($n) == "Up" } { Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ("foreach" body line 2) Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "foreach n $neighbors { Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: if { $states($n) == "Up" } { Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: set alldown 0 Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: break Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: } Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: }" Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "$slave eval $Contents" Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (procedure "eval_script" line 7) Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "eval_script slave $scriptname" Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: invoked from within Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: "if {$security_level == 1} { #untrusted script Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp create -safe slave Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdin slave Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: interp share {} stdout slave Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: ..." Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: (file "tmpsys:/lib/tcl/base.tcl" line 50) Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: Tcl policy execute failed: Oct 27 16:38:06.028: %HA_EM-6-LOG: sl_bgp_neighbor_watch.tcl: can't read "states(64.124.97.202)": no such element in array Oct 27 16:38:13.960: %TRACKING-5-STATE: 100 ip route 0.0.0.0/0 reachability Down->Up O #more disk2:sl_bgp_neighbor_watch.tcl ::cisco::eem::event_register_syslog pattern "BGP-5-ADJCHANGE: neighbor.*(Down|Up)" #- # Copyright (c) 2009 Joe Marcus Clarke # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT --More-- # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # # This policy watches for a specific syslog pattern to occur then checks # to see the state of all configured BGP neighbors. If all are down, then # EIGRP is unconfigured. When one neighbor comes back up, EIGRP is # reconfigured. # # This policy takes the following environment variable(s): # # bgp_watch_neighbors : Comma-separated list of BGP neighbors. # # bgp_watch_eigrp_as : EIGRP AS number. # # bgp_watch_eigrp_cfg : Comma-separated list of EIGRP commands to # configure when one BGP neighbor becomes # active. # # if { ! [info exists bgp_watch_neighbors] } { set result "ERROR: Policy cannot be run: variable bgp_watch_neighbors has not been set" error $result $errorInfo --More-- } if { ! [info exists bgp_watch_eigrp_as] } { set result "ERROR: Policy cannot be run: variable bgp_watch_eigrp_as has not been set" error $result $errorInfo } if { ! [info exists bgp_watch_eigrp_cfg] } { set result "ERROR: Policy cannot be run: variable bgp_watch_eigrp_cfg has not been set" error $result $errorInfo } namespace import ::cisco::eem::* namespace import ::cisco::lib::* proc run_cli { clist } { set rbuf "" if {[llength $clist] < 1} { return -code ok $rbuf } --More-- if {[catch {cli_open} result]} { return -code error $result } else { array set cliarr $result } if {[catch {cli_exec $cliarr(fd) "enable"} result]} { return -code error $result } if {[catch {cli_exec $cliarr(fd) "term length 0"} result]} { return -code error $result } foreach cmd $clist { if {[catch {cli_exec $cliarr(fd) $cmd} result]} { return -code error $result } append rbuf $result } --More-- if {[catch {cli_close $cliarr(fd) $cliarr(tty_id)} result]} { puts "WARNING: $result" } return -code ok $rbuf } array set arr_einfo [event_reqinfo] set msg $arr_einfo(msg) if { ! [regexp {BGP-5-ADJCHANGE:.*neighbor ([\d\.]+).*(Down|Up)} $msg -> neighbor state] } { error "Failed to parse syslog message: '$msg'" $errorInfo } set neighbors [split $bgp_watch_neighbors ","] array set states [list] if { [catch {context_retrieve BGPCTXT states} result] } { foreach n $neighbors { set states($n) "Up" } } --More-- foreach n [array names states] { if { $n == "__alldown__" } { continue } if { [lsearch -exact $neighbors $n] == -1 } { set states($n) "Up" } } set states($neighbor) $state set alldown 1 foreach n $neighbors { if { $states($n) == "Up" } { set alldown 0 break } } if { $alldown } { action_syslog priority emerg msg "All BGP neighbors are down; removing EIGRP" --More-- run_cli [list "config t" "no router eigrp $bgp_neighbor_eigrp_as" "end"] } elseif { [info exists states(__alldown__)] && $states(__alldown__) == 1 } { action_syslog msg "BGP neighbor $neighbor has come backup; reconfiguring EIGRP" set eigrp_cmds [split $bgp_watch_eigrp_cfg ","] set cmds [list "config t"] foreach c $eigrp_cmds { lappend cmds $c } lappend cmds "end" run_cli $cmds } set states(__alldown__) $alldown if { [catch {context_save BGPCTXT states} result] } { error "Failed to save state context: '$result'" $errorInfo }