cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3084
Views
0
Helpful
5
Replies

Basic traceroute EEM script (for hop-by-hop network analysis)

jsuddart
Level 1
Level 1

I'd like to do a hop-by-hop analysis by running a traceroute script that runs on an interval (say every 5-15 minutes) and puts output to a file.

The goal is to let the script run for a day, and see what kind of hop changes might occur over time, and also monitor for any latency increase or packetloss at certain times of day (peak hours).

If I used an EEM script to do a basic traceroute from one endpoint of the network to a server in the core (for instance), this could show how a client's path may be impacted during peak hours.

I'd want the output stored in a file on the router's flash disk, and then I'd have to find some way to parse and analyze the output later (not sure how I'd do that, perhaps with excel or another diff-like program).

5 Replies 5

jsuddart
Level 1
Level 1

I forgot to mention, the script would in this case be run from a CMTS router (near the edge/access), to a server which may be anywhere from 6-12 hops away in the network.

Joe Clarke
Cisco Employee
Cisco Employee

There's no questiom here.  Are you saying you want someone to write this policy, or are you writing it and running into specific problems?

Yes - I meant to ask for a sample/example config for this, as I was surprised to not find one easily on Google

The endpoint would be a static IP address, so the script would not need to be dynamic except for setting a string of the destination IP to traceroute to.

Something like this should work for you.  In config mode, specify three EEM environment variables:

event manager environment traceroute_timer 600

event manager environment traceroute_target 10.1.1.1

event manager environment traceroute_file flash:/traceroute.txt

Then register this EEM Tcl policy:

::cisco::eem::event_register_timer watchdog time $traceroute_timer 

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*

array set arr_einfo [event_reqinfo]


if [catch {cli_open} result] {
    error $result $errorInfo
} else {
    array set cli1 $result
}

if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
    error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "traceroute $traceroute_target"} _cli_result] {
    error $_cli_result $errorInfo
}

set fd [open $traceroute_file a]

puts $fd [clock format [clock seconds]]
puts $fd $_cli_result

close $fd

# Close open cli before exit. catch {cli_close $cli1(fd) $cli1(tty_id)} result

rkhanso
Level 1
Level 1

jsuddart wrote:

I'd like to do a hop-by-hop analysis by running a traceroute script that runs on an interval (say every 5-15 minutes) and puts output to a file.

The goal is to let the script run for a day, and see what kind of hop changes might occur over time, and also monitor for any latency increase or packetloss at certain times of day (peak hours).

If I used an EEM script to do a basic traceroute from one endpoint of the network to a server in the core (for instance), this could show how a client's path may be impacted during peak hours.

I'd want the output stored in a file on the router's flash disk, and then I'd have to find some way to parse and analyze the output later (not sure how I'd do that, perhaps with excel or another diff-like program).

Or send the output to a syslog server/remote box.

Review Cisco Networking for a $25 gift card