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_reqinfo
event 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
Summary of Contents for Catalyst 2960 Series
Page 96: ......
Page 196: ......
Page 250: ......
Page 292: ......
Page 488: ......
Page 589: ...P A R T VI Cisco Flexible NetFlow Configuring NetFlow Lite page 509 ...
Page 590: ......
Page 619: ...P A R T VII QoS Configuring QoS page 539 Configuring Auto QoS page 645 ...
Page 620: ......
Page 750: ......
Page 1604: ......
Page 1740: ......
Page 2105: ...P A R T XII Configuring Cisco IOS IP SLAs Configuring Cisco IP SLAs page 2025 ...
Page 2106: ......
Page 2118: ......
Page 2164: ......