cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1271
Views
0
Helpful
1
Replies

EEM TCL Script for multiple Interfaces

Ale Salgado
Cisco Employee
Cisco Employee

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

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

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

View solution in original post

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

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