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

ASR9K eem script to shutdown interface

marios.soteriou
Level 1
Level 1

Hello, 

this is my first time trying to do eem script.

I want a script that will look the syslog for the message "track 2 state Track_Down" and if found, shut down an interface.

I created the file (based on what i have found from other users) but it seems that i am missing something.

Thank you !!!

 

Router global config:

event manager environment _syslog_pattern .*(track 2 state Track_Down)
event manager directory user policy disk0:
event manager policy test-link-down.tcl username eem persist-time 3600

 

I have also created user eem under admin config.

 

Below is the script config 

 

::cisco::eem::event_register_syslog pattern {.*track 2 state Track_Down.*}

 

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

array set arr_einfo [event_reqinfo]


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) "conf t"} _cli_result] {
error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "int Gi0/0/0/3.100"} _cli_result] {
error $_cli_result $errorInfo
}

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

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

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


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

1 Reply 1

marios.soteriou
Level 1
Level 1

Hi,

 

i think the problem was with my timing. I added the maxrun 90 (default maxrun is 20 sec) and it looks that is working now. 

I will add another eem to do no shut on the interface when the track state changes to up and test it again later.

 

::cisco::eem::event_register_syslog pattern {.*track 2 state Track_Down.*} maxrun 90