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. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

Cisco Employee

EEM TCL Script for multiple Interfaces

Hi,

Im trying to run a TCL script on an ASR9k for detecting some flapping interfaces. I have done it for one interface and it is working, but when I try to use tags is not working

::cisco::eem::event_register_syslog tag t1 pattern "Interface GigabitEthernet0/0/0/0, changed state to Administratively Down"
::cisco::eem::event_register_syslog tag t2 pattern "Interface GigabitEthernet0/0/0/1, changed state to Administratively Down"

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

::cisco::eem::trigger {

::cisco::eem::correlate event t1 or t2

::cisco::eem::attribute tag t11 occurs 2

::cisco::eem::attribute tag t2 occurs 2
}

array set event_details [event_reqinfo_multi]

regexp {Interface ([a-z,A-Z,\d,\/]*\d)} $event_details(msg) interface


action_syslog msg "Warning! Conectivity is lost for $interface"

if { [catch {cli_open} result] } {
error $result $errorInfo
}

array set cli $result
cli_exec $cli(fd) "config"
cli_exec $cli(fd) "router ospf 100"
cli_exec $cli(fd) "area 0"
cli_exec $cli(fd) "interface $interface"
cli_exec $cli(fd) "cost 65000"
cli_exec $cli(fd) "commit"
cli_exec $cli(fd) "end"


catch {cli_close $cli(fd) $cli(tty_id)}

puts OK

  • EEM Scripting
Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

The trigger block needs to

The trigger block needs to come right after the event spec lines.  You also have a typo in your attribute.  It should be tag "t1" and you have tag "t11".

Finally, when you use event_reqinfo_multi, you need to index the array by tags:

if { [info exists event_details(t1)] } {

    array set arr_einfo $event_details(t1)

} else {

    array set arr_einfo $event_details(t2)

}

regexp {Interface ([a-z,A-Z,\d,\/]*\d)} $arr_einfo(msg) interface

1 REPLY
Cisco Employee

The trigger block needs to

The trigger block needs to come right after the event spec lines.  You also have a typo in your attribute.  It should be tag "t1" and you have tag "t11".

Finally, when you use event_reqinfo_multi, you need to index the array by tags:

if { [info exists event_details(t1)] } {

    array set arr_einfo $event_details(t1)

} else {

    array set arr_einfo $event_details(t2)

}

regexp {Interface ([a-z,A-Z,\d,\/]*\d)} $arr_einfo(msg) interface

3
Views
0
Helpful
1
Replies
This widget could not be displayed.