![Cisco ASR 9000 Serie Скачать руководство пользователя страница 60](http://html.mh-extra.com/html/cisco/asr-9000-serie/asr-9000-serie_configuration-manuals_66679060.webp)
Embedded Event Manager Scripts and the Scripting Interface (Tcl)
EEM scripts are used to implement policies when an EEM event is published. EEM scripts and policies are
identified to the EEM using the
event manager policy
configuration command. An EEM script remains
available to be scheduled by the EEM until the
no event manager policy
command is entered.
The EEM uses these two types of EEM scripts:
•
Regular
EEM scripts identified to the EEM through the
eem script
CLI command. Regular EEM scripts
are standalone scripts that incorporate the definition of the event they will handle.
•
EEM callback
scripts identified to the EEM when a process or EEM script registers to handle an event.
EEM callback scripts are essentially named functions that are identified to the EEM through the C
Language API.
This example shows the usage for the CLI in scripts:
sjc-cde-010:/tftpboot/cnwei/fm> cat test_cli_eem.tcl
::cisco::eem::event_register_syslog occurs 1 pattern $_syslog_pattern maxrun 90
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
set errorInfo ""
# 1. query the information of latest triggered fm event
array set arr_einfo [event_reqinfo]
if {$_cerrno != 0} {
set result [format "component=%s; subsys err=%s; posix err=%s;\n%s" \
$_cerr_sub_num $_cerr_sub_err $_cerr_posix_err $_cerr_str]
error $result
}
set msg $arr_einfo(msg)
set config_cmds ""
# 2. execute the user-defined config commands
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}
if [catch {cli_exec $cli1(fd) "config"} result] {
error $result $errorInfo
}
if {[info exists _config_cmd1]} {
if [catch {cli_exec $cli1(fd) $_config_cmd1} result] {
error $result $errorInfo
}
append config_cmds $_config_cmd1
}
if {[info exists _config_cmd2]} {
if [catch {cli_exec $cli1(fd) $_config_cmd2} result] {
error $result $errorInfo
}
append config_cmds "\n"
append config_cmds $_config_cmd2
}
if [catch {cli_exec $cli1(fd) "end"} result] {
error $result $errorInfo
Cisco ASR 9000 Series Aggregation Services Router System Monitoring Configuration Guide, Release 4.2.x
44
Configuring and Managing Embedded Event Manager Policies
Embedded Event Manager Scripts and the Scripting Interface (Tcl)