cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
265
Views
0
Helpful
0
Replies
Highlighted
Beginner

Need help Cisco A9K EEM Scripts.(IOS-XR)

Dears,

 

I want to create EEM Script, when

{Node: 0/0/CPU0, state: BRINGDOWN} syslog occurs in A9K, it reloads the linecard.

 

 

Also when making the scripts, I refer to some example scripts on Google. I have no idea for creating EEM scripts.

 

Please check my scripts below.

"I omit the authentication parts to see the scripts easier."

 

 

::cisco::eem::event_register_syslog tag 1 pattern {Node: 0/0/CPU0, state: BRINGDOWN} maxrun 240
::cisco::eem::event_register_syslog tag 2 pattern {Node: 0/1/CPU0, state: BRINGDOWN} maxrun 240
::cisco::eem::event_register_syslog tag 3 pattern {Node: 0/2/CPU0, state: BRINGDOWN} maxrun 240
::cisco::eem::event_register_syslog tag 4 pattern {Node: 0/3/CPU0, state: BRINGDOWN} maxrun 240
::cisco::eem::event_register_syslog tag 5 pattern {Node: 0/4/CPU0, state: BRINGDOWN} maxrun 240
::cisco::eem::event_register_syslog tag 6 pattern {Node: 0/5/CPU0, state: BRINGDOWN} maxrun 240
::cisco::eem::event_register_syslog tag 7 pattern {Node: 0/6/CPU0, state: BRINGDOWN} maxrun 240
::cisco::eem::trigger {
::cisco::eem::correlate event 1
attribute tag 1 occurs 1
attribute tag 2 occurs 1
attribute tag 3 occurs 1
attribute tag 4 occurs 1
attribute tag 5 occurs 1
attribute tag 7 occurs 1
} occurs 1 period 7

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

# wait 50 miliseconds
# after 50

set errorInfo ""

#query the event info
array set event_details [event_reqinfo_multi]
array set arr_einfo $event_details(1)

#Extract the location of the message:
regexp {[0-9]\/[0-9]+\/CPU[0-9]} $arr_einfo(msg) LC_Location


#open a cli connection
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}


# Phase 1: issue the command
if [catch {cli_write $cli1(fd) "admin hw-module location $LC_Location reload force"} result] {
error $result $errorInfo
}

# Phase 2: Q&A phase
# wait for prompted question:
# Do you wish to continue?[confirm]
if [catch {cli_read_pattern $cli1(fd) "\[confirm\]"} result] {
error $result $errorInfo
}
# write a newline character
#if [catch {cli_write $cli1(fd) "\n"} result] {
# error $result $errorInfo
#}

# Phase 3: noninteractive phase
# wait for command to complete and the router prompt
if [catch {cli_read $cli1(fd) } result] {
error $result $errorInfo
} else {
set cmd_output $result
}

if [catch {cli_close $cli1(fd) $cli1(tty_id)} result] {
error $result $errorInfo
}

action_syslog priority info msg "EEM script were excution successfully to reloading Node $LC_Location"

0 REPLIES 0