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

EEM or TCL script to 'clear xconnect int vlan$'

I'm looking for some guidance as I'm not real strong in this area.

My imagined script would match a syslog entry and issue a 'clear xconnect interface vlan$' command in the cli.

The syslog entry would appear as follows:  %XCONNECT-5-PW_STATUS: MPLS peer 10.1.1.1 vcid 48, VC state DOWN, PW Err

The 'vcid' in the log entry corresponds to the Vlan interface so in this case the script runs 'clear xconnect ineterface vlan48' from the CLI.

Here is the caveat...

Issuing this command at the CLI will cause the same messasge to be logged immediately following execution of the command.  It will only happen once, but it will happen.  The script would have to somehow ignore this or use a timer to know that it ignores it if it happens within x number of seconds from eachother. 

Here's somewhat of a live example:

Jul 13 22:11:03.906: %XCONNECT-5-PW_STATUS: MPLS peer 10.1.1.1 vcid 48, VC state DOWN, PW Err <-matching syslog

Router#clear xconnect interface vlan 48 <-example of executed command

Jul 13 22:11:12.791: %XCONNECT-5-PW_STATUS: MPLS peer 10.1.1.1 vcid 48, VC state ADMIN DOWN

Jul 13 22:11:12.791: %XCONNECT-5-PW_STATUS: MPLS peer 10.1.1.1 vcid 48, VC state DOWN

Jul 13 22:11:12.795: %XCONNECT-5-PW_STATUS: MPLS peer 10.1.1.1 vcid 48, VC state DOWN, PW Err <-recurrance of matching syslog/result of CLI command which would cause script to continusously loop (i think)

Jul 13 22:11:12.795: %XCONNECT-5-PW_STATUS: MPLS peer 10.1.1.1 vcid 48, VC state ADMIN DOWN

Jul 13 22:11:12.795: %XCONNECT-5-PW_STATUS: MPLS peer 10.1.1.1 vcid 48, VC state DOWN, Loc AC Err

Jul 13 22:11:12.803: %LINK-3-UPDOWN: Interface Vlan48, changed state to down

Jul 13 22:11:12.803: %HSRP-5-STATECHANGE: Vlan48 Grp 48 state Active -> Init

Jul 13 22:11:12.807 MST: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan48, changed state to down

I think this is simply solved for somebody with a better knowledge than I on writing these scripts.  Any guidance is greatly appreciated.

Everyone's tags (3)
3 REPLIES
Cisco Employee

EEM or TCL script to 'clear xconnect int vlan$'

What version of IOS will this run under?  Could multiple PWs have a problem at the same time?

New Member

EEM or TCL script to 'clear xconnect int vlan$'

Thanks for your time in responding Joseph.  You bring up an excellent question.

First, the platform is a Cisco 7600 series router and it is running IOS 15.2(2)S1.

Secondly, yes.  Ultimately, the router is a point of aggregation for many attachement circuit terminations and the script would need to be able to operate and behave in such a way that it can react to many PWs going down simultaneously. 

Another source I am working with brought up the idea of using [occurs num-occurrences] [period period-value] from 'event syslog'.

Does this provide enough information?

Thanks again.

Cisco Employee

Re: EEM or TCL script to 'clear xconnect int vlan$'

I think this Tcl policy will do what you need.  It uses contexts to make sure the next syslog for a given vcid is ignored.

::cisco::eem::event_register_syslog pattern "XCONNECT-5-PW_STATUS: MPLS peer.*VC state DOWN, PW Err"

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*

array set arr_einfo [event_reqinfo]

set _regexp_result [regexp {vcid ([0-9]+)} $arr_einfo(msg) -> vcid]
if {$_regexp_result == 0} {
    exit 0
}

if {! [catch {set state [context_retrieve XCONN_VCID_$vcid state]} errmsg]} {
    exit 0
}

if [catch {cli_open} result] {
    error $result $errorInfo
} else {
    array set cli1 $result
}

if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
    error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "clear xconnect interface vlan $vcid"} _cli_result] {
    error $_cli_result $errorInfo
}

set state 1

if {[catch {context_save XCONN_VCID_$vcid state} errmsg]} {
    puts "context_save failed: $errmsg"
}

# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result

1931
Views
0
Helpful
3
Replies
CreatePlease login to create content