01-18-2017 11:38 AM
I have two questions:
1) If I try to register script (at the end of post) I receive an error. Why?
R5#dir flash: | inc find
276 -rw- 585 Jan 17 2017 22:39:58 +00:00 find.tcl
R5(config)#event manager directory user policy flash:
R5(config)#event manager policy find.tcl
EEM Register event failed: Error empty reg spec, policy does not start with EEM registration commands.
EEM configuration: failed to retrieve intermediate registration result for policy find.tcl
When I use tclsh all works fine:
R5#tclsh find.tcl interface 192.168
interface GigabitEthernet0/0
ip address 192.168.88.252 255.255.255.0
duplex auto
speed auto
media-type rj45
2) Joe Clarke has wrote:"These days I do not recommend using tclsh for any production use if you don't have to"
What problem we will have with similar scripts if we try to use it on regular basis with tclsh, not eem?
SCRIPT:
set file [open nvram:/startup-config]
set section 0
set ok 0
while {[gets $file line] >= 0} {
switch -regexp -- $line {
{^\w} {
if {[regexp [lindex $argv 0] $line]} {
set section $line
}
}
{^\s} {
lappend subcommands $line
if {[regexp [lindex $argv 1] $line]} {
set ok 1
}
}
{^!$} {
if {$section != 0} {
if {$ok == 1} {
puts $section
foreach subcommand $subcommands {
puts $subcommand
}
}
}
set subcommands 0
unset subcommands
set section 0
set ok 0
}
}
}
close $file
Solved! Go to Solution.
01-20-2017 01:06 PM
What you have here is a tclsh script not an EEM Tcl policy. You need to properly convert this to an EEM Tcl policy (see http://www.cisco.com/c/en/us/td/docs/ios/netmgmt/configuration/guide/12_2sx/nm_12_2sx_book/nm_eem_policy_tcl.html). ; On top of that, opening NVRAM directly in EEM Tcl likely won't work. You should use the "show startup" CLI command to grab the startup configuration.
The problems with tclsh include lack of AAA integration and lack of good debuggability.
01-20-2017 01:06 PM
What you have here is a tclsh script not an EEM Tcl policy. You need to properly convert this to an EEM Tcl policy (see http://www.cisco.com/c/en/us/td/docs/ios/netmgmt/configuration/guide/12_2sx/nm_12_2sx_book/nm_eem_policy_tcl.html). ; On top of that, opening NVRAM directly in EEM Tcl likely won't work. You should use the "show startup" CLI command to grab the startup configuration.
The problems with tclsh include lack of AAA integration and lack of good debuggability.
01-20-2017 11:44 PM
Thanks Joe!
Are there any difference in performance?
When I use this script with tclsh I see that CPU utilization graph get some spikes. Will the same with EEM?
Or we can't suppose and we have to probe?
01-21-2017 07:21 AM
EEM Tcl uses the same underlying Tcl interpreter, so you will see similar CPU trends.
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