cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2534
Views
0
Helpful
3
Replies

Schedule TCLSH script to run at intervals

DAVID
Level 3
Level 3

How can I take the following tcl and with EEM schedule it so the router pings the list of IP addresses every 2, 6, 8,  or 24 hours?

router# tclsh
router(tcl)#foreach address {
10.x.x.201
10.x.x.201
10.x.x.202
10.x.x.203
10.x.x.204
10.x.x.205
10.x.x.206
10.x.x.207
10.x.x.208
10.x.x.209
10.x.x.210
10.x.x.211
10.x.x.212
} {

ping $address
}

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

You don't need Tcl to do this.  You could do it with an applet:

event manager environment addresses 10.x.x.201 ... 10.x.x.212

!

event manager applet ping-addrs

 event timer cron cron-entry "0 0,2,8,16 * * *"

 action 1.0 cli command "enable"

 action 2.0 foreach addr $addresses

 action 3.0  cli command "ping $addr"

 action 4.0 end

How do I know this works?  When I run the TCLSH I can see the output on the screen that the pings are successful.  How do I verify that the event manager applet is successful?

It depends on how you want the output.  You can send it via syslog by adding:

action 3.1 syslog msg "$_cli_result"

Or create an email with:

action 1.1 set results ""

action 3.1 append results $_cli_result

action 4.1 mail to "user@company.com" from "user@company.com" server "10.1.1.1" subject "Ping Results" body "$results"