Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 

How To Run an EEM Policy Every Time a Device Boots

There are at least three good ways to run an Embedded Event Manager policy every time a device boots up.  Two of the methods involve using timer policies while one uses a syslog policy.  These methods will work for any device running EEM 2.0 or higher.  See https://supportforums.cisco.com/docs/DOC-8799 on how to determine your version of EEM.  Let's look at the syslog policy first.

When a device boots, it will generate a %SYS-5-RESTART syslog message.  EEM can intercept this message and take your required boot up actions.  The following are example event registration lines for this method.

Applet:

event syslog pattern "SYS-5-RESTART"

Tcl:

::cisco::eem::event_register_syslog pattern "SYS-5-RESTART"

The second method involves using a countdown timer.  When the timer policy is registered it will begin to countdown the specified number of seconds.  At boot time, the policy will be read from the startup configuration and registered with EEM.  At that point, the timer begins.  The advantage of this approach is that you can inject some delay after the device comes online before the EEM policy runs.  However, there is a down side.  When you configure this policy, it will countdown to zero then run.  If you'd rather not have this run after first configuring it, download the startup-config, and add the commands to register your policy.  Then copy that configuration back into the startup-config.

The following are example event registration lines for this method.  They will run the policy ten seconds after the device boots and configures itself.

Applet:

event timer countdown time 10

Tcl:

::cisco::eem::event_register_timer countdown time 10

The final example uses a cron timer with a special cron-entry.  A policy registered in such a way will generally run within a minute after the device is booted.  The following are example event registration lines for this method.

Applet:

event timer cron cron-entry "@reboot"

Tcl:

::cisco::eem::event_register_timer cron cron_entry "@reboot"
Comments
Community Member

Thanks Joe, this is exactly what I was looking for.    

9677
Views
25
Helpful
1
Comments