cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1501
Views
0
Helpful
1
Replies

tcl scripts to run on syslog event

sanjethi
Level 1
Level 1

I'm trying to create a TCL script that will run automatically when it sees a specific log message. Once that syslog message appears it should then send pings to a couple of addresses(as well as grab output of show ip eigrp neighbrs) and save the output to a file on bootflash:

I found an example of how to store the output of the pings but i am not sure on 2 things.

1. How do i store the output of show ip eigrp neighbors to teh same ping file

2. how do i get the script to trigger on the following syslog message: %DUAL-5-NBRCHANGE

3. Also would it be possible to have this run a few times and to keep appending to the same file so that each time eigrp flaps, we don't delete what was in the ping file from the previous flap?

Here is the code i have currently

set fd [open "bootdisk:ping.txt" w]

foreach address {192.168.1.1 224.0.0.10} {

set output [exec "ping $address repeat 5 source g0/0/0 timeout 1"]

puts $fd $output

}

foreach address {192.168.1.2 224.0.0.10} {

set output [exec "ping $address repeat 5 source g1/0/0 timeout 1"]

puts $fd $output

}

exec show ip eigrp neighbors  <<<<<<<<<<<<< how do i store the output of this command to the same ping file.

close $fd

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

You should look through the Documents tab in this community as this is a fairly basic EEM question.  You can also run "more tmpsys:/lib/tcl/eem_scripts/sl_intf_down.tcl" on an IOS router to see an example EEM Tcl script that will react to a syslog message and run some CLI commands.  Since you already have a file open, you can use the exact same "puts" mechanism to write the additional output to this file.

Review Cisco Networking for a $25 gift card