cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4702
Views
5
Helpful
11
Replies

TCL failing when added to event manager policy

Travis Cassell
Level 1
Level 1

I found this sample script from section 2.1.7 of the CUBE Management guide,

http://www.cisco.com/en/US/partner/prod/collateral/voicesw/ps6790/gatecont/ps5640/white_paper_c11-613550_ps10536_Products_White_Paper.html

I'm trying to add it to monitor dial-peer up/down status.  I'm using the exact code listed in the guide;

::cisco::eem::event_register_timer watchdog time $check_interval nice 1

#

# Namespace imports

#

namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

#--- Check required environment variable(s) has been defined

if {![info exists dial_peer_number]} {

set result "EEM Policy Error: variable dial_peer_number has not been set"

error $result $errorInfo

}

#------------------- " cli open" -------------------

if [catch {cli_open} result] {

error $result $errorInfo

} else {

array set cli $result

}

#----------------------- "enable" ----------------------

if [catch {cli_exec $cli(fd) "enable"} result] { error $result $errorInfo }

#-------------- grab sip ood options-ping and track status --------------

if [catch {cli_exec $cli(fd) "show dial-peer voice $dial_peer_number | inc options-keepalive dial-peer action"} result] {

error $result $errorInfo

}

set cmd_output $result

if [catch {cli_exec $cli(fd) "show track $dial_peer_number | inc State"} result] { error $result $errorinfo

}

set track_state $result

#-------------- set stub status --------------

if [string match "*busyout*" $cmd_output] {

if [string match "*Up*" $track_state] {

if [catch {cli_exec $cli(fd) "conf t" } result] { error $result $errorInfo }

if [catch {cli_exec $cli(fd) "track $dial_peer_number stub-object" } result]

{ error $result $errorInfo }

if [catch {cli_exec $cli(fd) "default-state down" } result]

{ error $result $errorInfo }

if [catch {cli_exec $cli(fd) "end" } result] { error $result $errorInfo }

}

}

if [string match "*active*" $cmd_output] {

if [string match "*Down*" $track_state] {

if [catch {cli_exec $cli(fd) "conf t" } result] { error $result $errorInfo }

if [catch {cli_exec $cli(fd) "track $dial_peer_number stub-object" } result]

{ error $result $errorInfo }

if [catch {cli_exec $cli(fd) "default-state up" } result]

{ error $result $errorInfo }

if [catch {cli_exec $cli(fd) "end" } result] { error $result $errorInfo }

}

}

#--------------------- cli close ------------------------

if [catch {cli_close $cli(fd) $cli(tty_id)} result] {

error $result $errorInfo

}

I can insert it with the open, closed and enable sections but when I add the set stub status section I get the following;

router(config)#event manager policy check_dial_peer_status.tcl  

EEM Register event failed:wrong # args: no script following "[catch {cli_exec $cl" argument

    while compiling

"if [catch {cli_exec $cli(fd) "track $dial_peer_number stub-object" } result]"

    ("if" then script line 3)

    while compiling

"if [string match "*Up*" $track_state] {

if [catch {cli_exec $cli(fd) "conf t" } result] { error $result $errorInfo }

if [catch {cli_exec $cli(fd) "tra..."

    ("if" then script line 2)

    while compiling

"if [string match "*busyout*" $cmd_output] {

if [string match "*Up*" $track_state] {

if [catch {cli_exec $cli(fd) "conf t" } result] { error $result $e..."

EEM configuration: failed to retrieve intermediate registration result for policy check_dial_peer_status.tcl

I've had someone that nows TCL take a look and everything appears to be good but I can't get it to take.  Can anyone assist?

Thanks

Travis

11 Replies 11

Joe Clarke
Cisco Employee
Cisco Employee

I pointed out some problems with this script a while back to them, but I guess they never fixed it.  Here is an improved version that should work for you.

Thanks Joseph, I'll have to check them out in the moring.  I'll let you know how it goes.

Thanks

Travis

The TCL script took but not totally sure everything is working since it's my first time working with EEM.  Thanks for the help Joseph.

Busy out one of your dial-peers, and the script should set the tracked object corresponding to your dial-peer to down.

Doesn't it use the options-keepalive action in the sh dial-peer voice instead of the actual dial-peer status?  I shut the dial-peer and didn't get an alert. 

While the dial-peer was shut I ran "sh dial-peer voice 900 | inc options-keepalive dial-peer action" and it returned nothing but when I do it when the dial peer is up I get "voice class sip options-keepalive dial-peer action = active"

I guess an ACL blocking traffic would work to test wouldn't it?

So I setup a test dial-peer and I get the busyout and the track set to down but it doen't trigger anything.

Here's the histroy,

router#show event manager history events                               

No.  Job Id Proc Status   Time of Event            Event Type         Name

1    331    Actv success  Tue Jun19 10:19:04 2012  timer watchdog     script: check_dial_peer_status.tcl

2    333    Actv success  Tue Jun19 10:19:36 2012  track              applet: siptrunk_down

3    332    Actv success  Tue Jun19 10:19:34 2012  timer watchdog     script: check_dial_peer_status.tcl

4    334    Actv success  Tue Jun19 10:20:04 2012  timer watchdog     script: check_dial_peer_status.tcl

5    335    Actv success  Tue Jun19 10:20:34 2012  timer watchdog     script: check_dial_peer_status.tcl

6    336    Actv success  Tue Jun19 10:21:04 2012  timer watchdog     script: check_dial_peer_status.tcl

7    337    Actv success  Tue Jun19 10:21:34 2012  timer watchdog     script: check_dial_peer_status.tcl

8    338    Actv success  Tue Jun19 10:22:04 2012  timer watchdog     script: check_dial_peer_status.tcl

9    339    Actv success  Tue Jun19 10:22:34 2012  timer watchdog     script: check_dial_peer_status.tcl

10   340    Actv success  Tue Jun19 10:23:04 2012  timer watchdog     script: check_dial_peer_status.tcl

How do I tell if the actions are taking place?

event manager applet siptrunk_down

event track 904 state down

action 10 snmp-trap strdata "trunk DOWN"

action 20 syslog msg "trunk DOWN"

Thanks,

Travis

It looks like it's triggering your applet siptrunk_down based on the event history.  Are you not seeing the trap and/or syslog?

Now that I check I'm seeing it in the logging buffer but not on my syslog server.  I see the first line in syslog but not the second.

001708: *Jun 19 14:19:36.110: %TRACKING-5-STATE: 904 stub   Up->Down

001709: *Jun 19 14:19:36.122: %HA_EM-6-LOG: siptrunk_down: trunk DOWN

Do you know if this is informational?  We are only sending warnings to syslog so I guess that's what's happening.

These messages are informational, but sent using the same mechanism that sends debugging messages, so you will need to trap on debug to see them sent to syslog.

Thanks Joseph, quick question on the snmp-traps.  Do I have to install the MIB to get the traps?

Thanks,

Travis

No, but you do need to configure:

snmp-server enable traps event-manager

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: