06-20-2017 01:27 PM
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
Solved! Go to Solution.
06-21-2017 07:23 AM
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
06-21-2017 07:23 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide