I thought I could do this using only EEM but the traceroute command does not support |
So after searching and testing, i found what I think i need but i can't get it to work properly.
Basically, i want to kick off a traceroute when a router cannot ping a destination IP.
router in question is at 1.2.3.4
destination is 1.1.1.1
So start with the ip sla:
ip sla 1
icmp-echo 1.1.1.1 source-ip 1.2.3.4
threshold 800
timeout 1000
frequency 3
ip sla schedule 1 life forever start-time now
Tracking:
track 1 ip sla 1 reachability
delay down 15 up 15
EEM:
event manager applet trace_when_down
event track 1 state down
action 1.0 cli command "tclsh flash:tcl_trace_down.tcl"
Then the TCL
set fileoutput [open "flash:tracedown.txt" w]
foreach address {1.1.1.1} {
set output [exec "traceroute $address source g0/1"]
puts $fileoutput $output
}
close $fileoutput
Now, when I manually run the script it generates the proper output.
But when the tracking object goes down, eem says its action was successful but I get no output so I suspect i've done something incorrect.