event manager policy available [system |
RP/0/RP0/CPU0:Router# show event manager policy available
policies that are available to be registered.
|Step 2||Cut and paste
the contents of the sample policy displayed on the screen to a text editor.
|Step 3||Define the
required event_register Tcl command extension.
appropriate event_register Tcl command extension for the event that you want to
detect, and add it to the policy. The following are valid Event Registration
Tcl Command Extensions:
|Step 4||Add the
appropriate namespace under the ::cisco hierarchy.
developers can use the new namespace ::cisco in Tcl policies to group all the
extensions used by Cisco IOS XR EEM. There are two namespaces under the ::cisco
hierarchy. The following are the namespaces and the EEM Tcl command extension
categories that belongs under each namespace:
that the appropriate namespaces are imported, or use the qualified command
names when using the preceding commands.
|Step 5||Program the must
defines section to check for each environment variable that is used in this
This is an
optional step. Must defines is a section of the policy that tests whether any
EEM environment variables that are required by the policy are defined before
the recovery actions are taken. The must defines section is not required if the
policy does not use any EEM environment variables. EEM environment variables
for EEM scripts are Tcl global variables that are defined external to the
policy before the policy is run. To define an EEM environment variable, use the
EEM configuration command
. By convention, all Cisco EEM environment variables begin
with "_" (an underscore). To avoid future conflict, customers are urged not to
define new variables that start with "_".
display the Embedded Event Manager environment variables set on your system by
event manager environment
EEM environment variables defined by the sample policies include e-mail
variables. The sample policies that send e-mail must have the following
variables set in order to function properly. The following are the
e-mail-specific environment variables used in the sample EEM policies.
_email_server—A Simple Mail Transfer Protocol (SMTP) mail
server used to send e-mail (for example, mailserver.example.com)
_email_to—The address to which e-mail is sent (for example,
_email_from—The address from which e-mail is sent (for
_email_cc—The address to which the e-mail must be copied
(for example, firstname.lastname@example.org)
|Step 6||Program the
body of the script.
section of the script, you can define any of the following:
event_reqinfo event information Tcl command extension that
is used to query the EEM for information about the detected event.
Tcl command extensions, such as
action_syslog, that are used to specify actions specific to
information Tcl command extensions, such as
sys_reqinfo_routername, that are used to obtain general
context_retrieve Tcl command extensions that are used to
save Tcl variables for use by other policies.
Use of the
SMTP library (to send e-mail notifications) or the CLI library (to run CLI
commands) from a policy.
|Step 7||Check the
entry status to determine if a policy has previously run for this event.
If the prior
policy is successful, the current policy may or may not require execution.
Entry status designations may use one of three possible values: 0 (previous
policy was successful), Not=0 (previous policy failed), and Undefined (no
previous policy was executed).
|Step 8||Check the exit
status to determine whether or not to apply the default action for this event,
if a default action exists.
A value of
zero means that the default action should not be performed. A value of nonzero
means that the default action should be performed. The exit status is passed to
subsequent policies that are run for the same event.
|Step 9||Set Cisco
Error Number (_cerrno) Tcl global variables.
Some EEM Tcl
command extensions set a Cisco Error Number Tcl global variable _cerrno.
Whenever _cerrno is set, four other Tcl global variables are derived from
_cerrno and are set along with it (_cerr_sub_num, _cerr_sub_err, , and
|Step 10||Save the Tcl
script with a new filename, and copy the Tcl script to the router.
Manager policy filenames adhere to the following specification:
optional prefix—Mandatory.—indicating, if present, that this is a system policy
that should be registered automatically at boot time if it is not already
registered. For example: Mandatory.sl_text.tcl.
body part containing a two-character abbreviation (see
for the first event specified, an underscore character part, and a descriptive
field part further identifying the policy.
suffix part defined as .tcl.
details, see theCisco File Naming Convention for Embedded Event Manager.
Copy the file
to the flash file system on the router—typically disk0:.
event manager directory
RP/0/RP0/CPU0:Router(config)# event manager directory user library disk0:/user_library
directory to use for storing user library files or user-defined EEM policies.
event manager policy
username [persist-time [seconds |
RP/0/RP0/CPU0:Router(config)# event manager policy test.tcl username user_a type user
EEM policy to be run when the specified event defined within the policy occurs.
|Step 15||Cause the
policy to execute, and observe the policy.
|Step 16||Use debugging
techniques if the policy does not execute correctly.