Tcl Policy Structure and Requirements
All EEM policies share the same structure, shown in the figure below. There are two parts of an EEM policy
that are required: the event_register Tcl command extension and the body. The remaining parts of the policy
are optional: environment must defines, namespace import, entry status, and exit status.
Figure 112: 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 . 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 environment must defines section is optional and includes the definition of environment variables. 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_reqinfoevent information Tcl command extension that is used to query the EEM for
information about the detected event.
Consolidated Platform Configuration Guide, Cisco IOS Release 15.2(4)E (Catalyst 2960-X Switches)
1786
How to Write Embedded Event Manager Policies Using Tcl