cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
10018
Views
10
Helpful
14
Replies

EEM applet to run on reboot

paul-bergeron
Level 1
Level 1

I'm trying to figure out a way to cause an EEM applet to run on any reboot (command line requested reboot or a reboot caused by a power loss).  I can use the syslog event detector but that will only catch command line reboot requests.  

1 Accepted Solution

Accepted Solutions

The countdown timer policy should work in this case.  After the specified number of seconds expire, the policy should execute.  The countdown will start once the startup config has been loaded into the running config.

View solution in original post

14 Replies 14

Jon Marshall
Hall of Fame
Hall of Fame

Paul

The Cisco expert on EEM hangs out in the Network Infrastructure -> Network Management forum. If you move this thread to that forum you will get much better help.

Jon

Joe Clarke
Cisco Employee
Cisco Employee

Syslog should work for you.  Even if a router is power-cycled, you should see a SYS-5-RESTART message on the console when it boots.  An applet such as the following will work:

event manager applet on-boot

event syslog pattern "SYS-5-RESTART"

...

If you need more delay, you can use a countdown policy.  For example:

event manager applet on-boot

event timer countdown time 30

...

This policy will execute 30 seconds after it is registered (on a reload).  The downside of this approach is that the policy will run 30 seconds after it is initially configured as well unless you deploy it directly to the startup configuration.

There is also a special cron entry you can use to match on reboot:

event manager applet on-reboot

event timer cron cron-entry "@reboot"

...

Thanks for the replies!  These do work but the reboot of interest that I want this to work on is a reboot implemented in performing a password recovery.  I know that the config is not loaded in doing a pw recovery until the console user implements a copy start run but I was hoping that once it was copied, that the applet would fire off.  The cron entry you recommended works on a CLI reboot request and a power cycle reboot but if the power cycle reboot also incorporates ctrl+break, config-reg changes and copy start run, it seems to prevent the applet from running.  Any ideas?  Thanks again for your help. 

The countdown timer policy should work in this case.  After the specified number of seconds expire, the policy should execute.  The countdown will start once the startup config has been loaded into the running config.

Thank you sir!

Here is how the scipt can look like. I use it for EVE-NG where routers ignore no shut command in the startup config for some reason forcing me to console in and unshut ... or use EEM

event timer countdown name ON_REBOOT max 10 time 15
action 100 cli command "enable"
action 110 cli command "configure terminal"
action 120 cli command "interface G0/0"
action 130 cli command "no shut"
action 140 cli command "end"
action 150 cli command "write"

The timer basically starts ticking on reboot, taking action only 1x you might need to give it larger value on real equipment to ensure that the EEM applet registered and IOS was responding to it. You could also upgrade it a bit with IP SLA that could react multiple times -- event track 1 state down

I'm trying to achieve something similar, but what I'm looking to do is keep all interfaces shutdown on a 3548 for two minutes after reboot. Any thoughts how I can go about this?

Hello,

 

what state are the interfaces in on reboot, shut, or no shut ?

In steady state, interfaces will be in no-shut or enabled stated. However I wanted to keep interfaces down for two minutes after the reboot till it's processors are up and stable. 

Hello,

 

you could use a wait timer:

 

event manager applet on-reboot
event timer cron cron-entry "@reboot"
action 1.0 cli command "enable"
action 2.0 cli command "configure terminal"
action 3.0 cli command "interface range G0/0 - 48"
action 4.0 cli command "shut"
action 5.0 wait 120
action 6.0 cli command "no shut"
action 7.0 cli command "end"

Thanks @Georg Pauwen, however "timer" is not an option available. I've only got 

cli

counter

fanabsent

fanbad

fib

gold

internal-link-flap

memory

module

module-failure

neighbor-discovery

oir

policy-default

poweroverbudget

snmp

storm-control

syslog

sysmgr

tag

temperature

test

track

 

No timer option under event. 

Hello,

 

could be your EEM version, or your platform. Try the syslog instead:

 

event manager applet REBOOT
event syslog pattern "SYS-5-RESTART"
action 1.0 cli command "enable"
action 2.0 cli command "configure terminal"
action 3.0 cli command "interface range G0/0 - 48"
action 4.0 cli command "shut"
action 5.0 wait 120
action 6.0 cli command "no shut"
action 7.0 cli command "end"

I believe it is to do with Nexus 3K EEM version, unfortunately "wait" is not an available option either. I'm thinking of calling a python script to get this done. 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: