![Cisco ASR 9000 Serie Configuration Manuals Download Page 83](http://html.mh-extra.com/html/cisco/asr-9000-serie/asr-9000-serie_configuration-manuals_66679083.webp)
and the body. The remaining parts of the policy are optional: environmental must defines, namespace import,
entry status, and exit status.
Figure 2: Tcl Policy Structure and Requirements
The start of every policy must describe and register the event to detect using an
event_register
Tcl command
extension. This part of the policy schedules the running of the policy. For a list of the available EEM
event_register
Tcl command extensions, see the
Embedded Event Manager Event Registration Tcl Command
Extensions, on page 94
. The following example Tcl code shows how to register the
event_register_timer
Tcl command extension:
::cisco::eem::event_register_timer cron name crontimer2 cron_entry $_cron_entry maxrun 240
The following example Tcl code shows how to check for, and define, some environment variables:
# Check if all the env variables that we need exist.
# If any of them does not exist, print out an error msg and quit.
if {![info exists _email_server]} {
set result \
"Policy cannot be run: variable _email_server has not been set"
error $result $errorInfo
}
if {![info exists _email_from]} {
set result \
"Policy cannot be run: variable _email_from has not been set"
error $result $errorInfo
}
if {![info exists _email_to]} {
set result \
"Policy cannot be run: variable _email_to has not been set"
error $result $errorInfo
)
The namespace import section is optional and defines code libraries. The following example Tcl code shows
how to configure a namespace import section:
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
The body of the policy is a required structure and might contain the following:
•
The
event_reqinfo
event information Tcl command extension that is used to query the EEM for
information about the detected event. For a list of the available EEM event information Tcl command
extensions, see the
Embedded Event Manager Event Information Tcl Command Extension, on page
129
.
Cisco ASR 9000 Series Aggregation Services Router System Monitoring Configuration Guide, Release 4.2.x
67
Configuring and Managing Embedded Event Manager Policies
How to Write Embedded Event Manager Policies Using Tcl