02-13-2012 11:03 PM
I want to restart a voice port on a router at a regular time.
This is what i setup so far:
R#tclsh
R#
puts [open flash:reset-000.tcl w+] {
tclsh
ios_config "voice-port 0/0/0" "shut"
after 5
ios_config "voice-port 0/0/0" "no shut"
}
The exec command does not work, it isn't there.
Am i missing something?
How can i test to see if the port shuts down.
Router IOS Version 12.4
Solved! Go to Solution.
02-17-2012 04:41 PM
You can't use applets to do exactly what you want, but you can use an EEM Tcl policy. For example, this should work for you.
::cisco::eem::event_register_timer watchdog time 3600
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
if { [catch {cli_open} result] } {
error $result $errorInfo
}
array set cli $result
if { [catch {cli_exec $cli(fd) "enable"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "config t"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "voice-port 0/0/0"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "shut"} result] } {
error $result $errorInfo
}
# sleep for five seconds
after 5000
if { [catch {cli_exec $cli(fd) "no shut"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "end"} result] } {
error $result $errorInfo
}
catch {cli_close $cli(fd) $cli(tty_id)}
This gets saved to a file on flash. For example, save it as:
flash:no_bounce_voip.tcl
Then, configure:
event manager directory user policy flash:
event manager policy no_bounce_voip.tcl
02-23-2012 10:15 AM
Older versions required a "name" argument. Change the first line to:
::cisco::eem::event_register_timer watchdog time 3600 name bounce_timer
02-14-2012 12:51 PM
What version of 12.4 do you have? What is the full image name? You might be able to do this with EEM applets rather than Tcl.
02-14-2012 10:27 PM
(C2800NM-IPVOICE_IVS-M), Version 12.4(22)YB8, RELEASE SOFTWARE (fc1)
02-17-2012 04:41 PM
You can't use applets to do exactly what you want, but you can use an EEM Tcl policy. For example, this should work for you.
::cisco::eem::event_register_timer watchdog time 3600
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
if { [catch {cli_open} result] } {
error $result $errorInfo
}
array set cli $result
if { [catch {cli_exec $cli(fd) "enable"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "config t"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "voice-port 0/0/0"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "shut"} result] } {
error $result $errorInfo
}
# sleep for five seconds
after 5000
if { [catch {cli_exec $cli(fd) "no shut"} result] } {
error $result $errorInfo
}
if { [catch {cli_exec $cli(fd) "end"} result] } {
error $result $errorInfo
}
catch {cli_close $cli(fd) $cli(tty_id)}
This gets saved to a file on flash. For example, save it as:
flash:no_bounce_voip.tcl
Then, configure:
event manager directory user policy flash:
event manager policy no_bounce_voip.tcl
02-19-2012 11:23 PM
Hi Joseph,
Thanks for you're answer. I save the file as no_bounce.voip.tcl to flash:
132 845 Feb 20 2012 07:27:10 no_bounce_voip.tcl
11141120 bytes available (118611968 bytes used)
I went to the switch in config mode and entered:
event manager directory user policy flash:
event manager policy no_bounce_voip.tcl
it looks like this in the config:
...........
event manager directory user policy "flash:/"
event manager policy no_bounce_voip.tcl
!
end
................
How can i test it. I have terminal monitor and debug turned on and nothing happens.
02-19-2012 11:58 PM
Many thanks for the post:
It worked on my lab router:
(C2800NM-IPVOICE_IVS-M), Version 12.4(22)YB8
I want to put the EEM in production on another router :
(C2800NM-ADVIPSERVICESK9-M), Version 12.4(23)
after the command event manager policy no_bounce_voip.tcl
i have the following output:
hq(config)#event manager policy no_bounce_voip.tcl
Compile check and registration failed:Wrong # args, usage is "::cisco::eem::event_register_timer watchdog|countdown|absolute|cron name ? cron_entry ? time ? queue_priority normal|low|high maxrun ? nice ?"
while executing
"::cisco::eem::event_register_timer watchdog time 3600
"
Tcl policy execute failed: Wrong # args, usage is "::cisco::eem::event_register_timer watchdog|countdown|absolute|cron name ? cron_entry ? time ? queue_priority normal|low|high maxrun ? nice ?"
Embedded Event Manager configuration: failed to retrieve intermediate registration result for policy no_bounce_voip.tcl: Unknown error 0
02-23-2012 10:15 AM
Older versions required a "name" argument. Change the first line to:
::cisco::eem::event_register_timer watchdog time 3600 name bounce_timer
02-24-2012 01:48 PM
Correct again. Many thanks !!!
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