filmov
tv
EEM Script on Cisco IOS XR Router
Показать описание
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."
#=============================================
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."
#=============================================
Комментарии