Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

TCL script restart voice port


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
Cisco Employee

Re: TCL script restart voice port

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

Cisco Employee

Re: TCL script restart voice port

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

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

7 REPLIES
Cisco Employee

TCL script restart voice port

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.

New Member

TCL script restart voice port

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

Cisco Employee

Re: TCL script restart voice port

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

New Member

TCL script restart voice port

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.

New Member

Re: TCL script restart voice port

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

Cisco Employee

Re: TCL script restart voice port

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

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

New Member

Re: TCL script restart voice port

Correct again. Many thanks !!!

1066
Views
5
Helpful
7
Replies
CreatePlease login to create content