11-09-2012 12:32 PM
Hi all,
I develop in script for sync setting the routers with HSRP. Follow Script tcl.
--------------------- flash0:sync_settings_hrsp.tcl ----------------
set filename_main "system:/running-config"
set main [open $filename_main r]
set nrLinha 0
while {[gets $main linha_main] >= 0} {
######### ROUTER0 ########
if [regexp -nocase {^hostname router0} $linha_main conteudo] {
set filename2 "flash:/running-config_router1"
set handle1 [open $filename_main r]
set handle2 [open $filename2 w]
set dados [read $handle1]
regsub -line -all {^hostname asrouter0} $dados "hostname router1" nomehost
regsub -line -all {^.ip address 192.168.1.2 255.255.255.0} $nomehost " ip address 192.168.1.3 255.255.255.0" fa0_0
regsub -line -all {^.ip address 192.168.2.2 255.255.255.0} $fa0_0 " ip address 192.168.2.3 255.255.255.0" fa0_1
puts $handle2 $fa0_1
close $handle1
close $handle2
}
########### ROUTER1 #############
if [regexp -nocase {^hostname router1} $linha_main conteudo] {
set filename2 "flash:/running-config_router0"
set handle1 [open $filename_main r]
set handle2 [open $filename2 w]
set dados [read $handle1]
regsub -line -all {^hostname router1} $dados "hostname router0" nomehost
regsub -line -all {^.ip address 192.168.1.3 255.255.255.0} $nomehost " ip address 192.168.1.2 255.255.255.0" fa0_0
regsub -line -all {^.ip address 192.168.2.3 255.255.255.0} $fa0_0 " ip address 192.168.2.2 255.255.255.0" fa0_1
puts $handle2 $fa0_1
close $handle1
close $handle2
}
}
close $main
------------------------------------------------------------------------------------------
And create the follow EEM
event manager applet cli-match
event cli pattern "write memory.*" sync yes
action 1.0 syslog msg "Syncing settings - HSRP"
action 1.1 cli command "tclsh flash0:sync_settings_hrsp.tcl"
action 1.2 cli command "copy flash0:running-config_router0 tftp://192.168.1.3/running-config_router0"
action 1.3 cli command "copy flash0:running-config_router1 tftp://192.168.1.3/running-config_router1"
set 2.0 _exit_status 1
____________________
I am intend to do and when you run the command "write memory" he raise the event and run the tcl script where it will only replace the ip address of the router interfaces and name and create another file "running-config" with the respective name of the router in flash. After that do the copy flash tftp to the other router leaving the other router with the updated configuration, but I tried and I generated the message "permission denied". But running it on hand if I use the event he runs EEM TCL but does not copy to another router via tftp. Any idea?
Regards.
Solved! Go to Solution.
11-12-2012 01:27 PM
EEM includes a Tcl inferface as well. More information can be found at
http://www.cisco.com/en/US/docs/ios/netmgmt/configuration/guide/nm_eem_policy_tcl.html .
11-11-2012 08:44 AM
You need to add:
action 0.5 cli command "enable"
However, I am always against wrapping tclsh in EEM when you could use EEM Tcl to accomplish what you want. This will greatly reduce the overhead on the device. You should consider rewriting your tclsh script into an EEM Tcl policy that does the processing and copying. That Tcl policy can also watch for "write mem".
11-12-2012 05:13 AM
Hi joseph.
not understand what you mean by "EEM Tcl" has some documentation?
Regards
11-12-2012 01:27 PM
EEM includes a Tcl inferface as well. More information can be found at
http://www.cisco.com/en/US/docs/ios/netmgmt/configuration/guide/nm_eem_policy_tcl.html .
11-16-2012 12:52 PM
Hi, Joseph.
you know if it is possible I connect to another router and make the application settings? Only via socket? or copy tftp (which this generating permission denied)?
Regards.
11-16-2012 12:56 PM
Socket is the best way to do this. I have a script (the Remote Command Shell) at http://www.cisco.com/go/easy that can be used to do stuff like this.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: