05-20-2020 09:46 AM
Hi ,
I have created a TCL script that is registered with the router EEM syslog event type with the intent to have it run everytime a router is rebooted/reloaded/powercycled etc. The idea is on boot up the event would be triggered once is sees the SYS-5-RESTART log message in the logging buffer...it however does not appear to be running on bootup...if i manually run the tcl script by creating a syslog message in the cli the script will run as written and works fine....it is possible that i just need to adjust the wait time "after 15000" not sure at this point
gas-carthage2-r01#show event manager policy registered
2 script user syslog Off Thu May 14 14:58:27 2020 cell_restart_normalize.tcl
pattern {SYS-5-RESTART}
nice 0 queue-priority normal maxrun 120.000 scheduler rp_primary Secu none
The script is suppose to wait a 15 seconds and then check to see if there are any active eigrp neighbors on any tunnel interface excluding Tunnel23, put the result in a variable and then check the variable to see if there are any active tunnels up...if so it would shutdown tunnel23...if no tunnels were found it would enable tunnel23 to bring cell backup online
here is the tcl script
gas-carthage2-r01#more flash:/scripts/cell_restart_normalize.tcl
#
#
# Triggered on reload
# Normalize Tu23 and Kron
#
#
::cisco::eem::event_register_syslog pattern SYS-5-RESTART maxrun 120
#
#
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
#
#
after 15000
set _neighbors [if { [catch {cli_open} result] } {
exit 1
} else {
array set cli $result
cli_exec $cli(fd) "show ip eigrp neighbors | ex Tu23"
}
]
if {[regexp {Tu2*} $_neighbors ] == 1 } {
cli_exec $cli(fd) "enable"
cli_exec $cli(fd) "config t"
cli_exec $cli(fd) "interface tu23"
cli_exec $cli(fd) "shutdown"
cli_exec $cli(fd) "do wr mem"
} else {
cli_exec $cli(fd) "enable"
cli_exec $cli(fd) "config t"
cli_exec $cli(fd) "interface tu23"
cli_exec $cli(fd) "no shutdown"
cli_exec $cli(fd) "kron occurrence CELL_DEACTIVATE in 0:0:30 recurring"
cli_exec $cli(fd) "end"
after 20000
cli_exec $cli(fd) "send log 6 Cell Backup Activated - Circuit Failure"
}
catch {cli_close $cli(fd) $cli(tty_id)}
gas-carthage2-r01#
Solved! Go to Solution.
05-20-2020 01:13 PM
Crontab timer can take reload as a setting. Here is an example of an event detector I use on a script to run at reboot or run it manually.
::cisco::eem::event_register_timer tag 1 cron name gps_geofence.tcl cron_entry "@reboot" maxrun 630
::cisco::eem::event_register_none tag 2
::cisco::eem::trigger {
::cisco::eem::correlate event 1 or event 2
}
Entire script is located here: https://community.cisco.com/t5/networking-documents/geo-fence/ta-p/3148081
05-20-2020 01:13 PM
Crontab timer can take reload as a setting. Here is an example of an event detector I use on a script to run at reboot or run it manually.
::cisco::eem::event_register_timer tag 1 cron name gps_geofence.tcl cron_entry "@reboot" maxrun 630
::cisco::eem::event_register_none tag 2
::cisco::eem::trigger {
::cisco::eem::correlate event 1 or event 2
}
Entire script is located here: https://community.cisco.com/t5/networking-documents/geo-fence/ta-p/3148081
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide