cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2009
Views
5
Helpful
7
Replies

TCL script restart voice port

Calin Cristea
Level 1
Level 1


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

2 Accepted Solutions

Accepted Solutions

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

View solution in original post

Older versions required a "name" argument.  Change the first line to:

::cisco::eem::event_register_timer watchdog time 3600 name bounce_timer

View solution in original post

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

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.

(C2800NM-IPVOICE_IVS-M), Version 12.4(22)YB8, RELEASE SOFTWARE (fc1)

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

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.

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

Older versions required a "name" argument.  Change the first line to:

::cisco::eem::event_register_timer watchdog time 3600 name bounce_timer

Correct again. Many thanks !!!

Getting Started

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: