EEM Script on Cisco IOS XR Router

preview_player
Показать описание
A short video about how to execute a EEM script on Cisco IOS XR routers.
Watch the video and use the below commands and script file in lab router for practice

#eemiosxr
#ciscoeem

Commands used in the Video
+++++++++++++++++++++++++

dir harddisk:/scripts location 0/RSP0/CPU0

If the directories do not exist, create them:

mkdir harddisk:/scripts location 0/RSP0/CPU0

- Verify that the script directory is already configured:

show run | i event manager directory

If it's not configured yet:

config t
event manager directory user policy harddisk:/scripts
commit
end

- Set all environment variables (if any are used by the script and instructed by Cisco)

conf t
event manager environment _cron_entry */5 * * * *
commit
end

- Configure authentication for EEM

config t

username event_manager_user
group root-system
group cisco-support

aaa authorization eventmanager default local
aaa authorization commands eem-method none

vty-pool eem 100 105 line-template eem-template

line template eem-template
authorization commands eem-method
!
commit

- Enable the script:

conf t
commit

Show command :
#show event manager policy registered
#dir harddisk: | i script-log

::cisco::eem::event_register_timer cron name crontimer cron_entry $_cron_entry maxrun_sec 600

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

set commands [ list \
"terminal length 0" \
"show platform" \
"show pfm location all" \
"show instal active summary" \
"admin show platform" \
]

#
# errorInf gets set by namespace if any of the auto_path directories do not
# contain a valid tclIndex file. It is not an error just left over stuff.
# So we set the errorInfo value to null so that we don't have left
# over errors in it.
#
set errorInfo ""

action_syslog priority info msg "EEM script was triggered"

# Open CLI
#
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli $result
}

#Run cmds

set tdate [clock format [clock seconds] -format %Y%m%d%H%M%S]
set outfile [open $filename w]
action_syslog priority info msg "Opened $filename"

foreach cmd $commands {
action_syslog priority info msg "Executing: $cmd"
puts $outfile "
+===============================================+
"
puts $outfile [ cli_exec $cli(fd) $cmd ]
}

# Close the CLI connection
cli_close $cli(fd) $cli(tty_id)
close $outfile

action_syslog priority info msg "File closed, script execution has finished."

#=============================================
Рекомендации по теме
Комментарии
Автор

Thanks for this great tutorial. I was finally able to simulate BGP conditional routing on IOS-XR using EEM scripts with the info provided here.

guammie
Автор

You put the TCL script in the description? You're awesome! thank you!

reza
Автор

Nice video man! In my case though I'm facing a hard time to make it work: apparently tcl script stucks on cli call part (the things under Open CLI function). if I remove it and add some syslog lines I can see some progress, but without file being generated). Running XR 5.3.3 (xrv).

EDIT: managed to make it work: for some odd reason it can't call CLI if XR hostname still the default one (ios). After change hostname to random one (XR) it worked just fine.

vitorbarboza
Автор

Can you post a video that will explain how this can be utilised to do some interactive scripting . Like : check reliability of link using show command if the reliability is less than 250 -- increase the ospf cost using eem

Or point towards some documentation ?.

Btw the router is using 32 bit IOSXR or 64 bit ?
Great video btw.

arjunaganesan
Автор

So could you guide me how to make tcl file to configure (interface shut/no shut etc) when the router hit syslog pattern, thank you.

tuananh
Автор

thanks for this video .. i want to creat a EEM depend on ip sla can you help me?

ammarmaan
Автор

Is ti possible to make IOS XR give command outputs dynamically ? like if I do "show history" it dynamically gives output when new history like adds in.

jeethuutube