cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2350
Views
0
Helpful
18
Replies

Conditional reload after shutting & upping an interface

Boo
Beginner
Beginner

Is there an easier way to perform nested applet actions i.e how to achieve the outcome using  If/else statement in one applet rather nested applets?

event manager applet Shut-NoShut

event track 3 state down

action 10 cli command "en"

action 20 cli command "conf t"

action 30 cli command "interface fa0/0"

action 40 cli command "shut"

action 50 cli command "unshut"

action 60 wait xx

action 70 cli command "event manager applet Reload-Applet"

action 80 cli command "event track 3 state down"

action 90 cli command "end"

action 100 cli command "write memory"

action 110 cli command "action 1 reload"

action 120 cli command "end"

!
event manager applet Router-Up

event track 3 state up

action 10 cli command "en"

action 20 cli command "conf t"

action 30 cli command "no event manager applet Reload-Applet"

action 40 cli command "end"

action 50 cli command "write memory"

action 60 cli command "end"

!

event manager applet WatchDogApplet

event track 3 state down

event timer watchdog time 86400

action 1 syslog msg "Adding a timer to track and reload every 24 hours when there is no Internet"

action 2 reload

action 3 end

18 Replies 18

Boo
Beginner
Beginner

Its strange that I can't have both event state track and watchdog timer in  one applet ?
Router is accepting both the state track and watch dog time, however when I do show run, track state is gone .. If I chnage the sequence while adding i.e., insert state track first and then watchdog, state track will be gone or if I do watchdog and then state track, watch dog is gone from the applet.

Any way to work around this ?

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

EEM policies historically have only had one event.  Multiple event support was added in EEM 2.4, but you need a slightly different syntax.  For example, to configure a policy with two events where either event can happen to trigger the policy:

event tag e1 timer watchdog time 60

event tag e2 track 3 state down

trigger

 correlate event e1 or event e2

Mine should definitely support multiple events, as a matter of fact my router was supporting until last night.

Embedded Event Manager Version 3.10
Component Versions:
eem: (v310_throttle)4.1.23
eem-gold: (v310_throttle)1.0.7
eem-call-home: (v310_throttle)1.0.6

2 Issues.
1) action 110 cli command "action 1 reload"
Throws an error and doesn't reload the router ?

2)The below command doesn't do anything.
When the state is down it doesn't even print the message? 

event manager applet WatchDogApplet
event tag e1 timer watchdog time 60
event tag e2 track 3 state down 
trigger correlate event e1 or event e2
action 1 syslog msg "Adding a timer to track and reload every 24 hours when there is no Internet"
action 2 reload
action 3 end

Sorry for being a newbie :)

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

action 110 is being run when in EXEC mode, so of course it's not going to do anything other than generate an error.  You need to relabel it action 85 to work with your current flow.

The trigger command needs to be entered on its own.  That will put you in trigger sub-mode where you configure the correlation.  Then, when the track transitions to a down state, that applet should execute.

Thanks for the prompt reply, if action 85 is to reload, then the router will not have enough time to write mem ?


Actually I had the trigger command on its own and I was in the sub mode. It was just a formatting mistake.
(config-applet-trigger#)

I actually had it like this

event manager applet WatchDogApplet 
 event tag e1 timer watchdog time 60 
 event tag e2 track 3 state down 
trigger
 correlate event e1 or event e2 

action 1 syslog msg "Adding a timer to track and reload every 24 hours when there is no Internet" 
action 2 reload 
action 3 end

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

Moving the action should not interrupt write mem unless the tracked object goes down the moment you leave config mode.

This applet looks fine.  Provided the tracked object actually transitions state to down, then it should run.  Of course, it will run automatically 60 seconds arfter it's registered.

When you say the applet will run automatically 60 seconds after it's registered. Did you mean the watchdog timer will reset every 60s and reloads the router or did you mean to say the timer will reset but however the actions will only be executed if the tracked objects state goes down?

 FYI: I am trying to achieve the later result.

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

The applet will execute either when the tracked object goes down (not if it's already down) or when 60 seconds goes by after the applet is registered.

Is there any way I can add a Boolean or so that the it will only get executed after the timer expires but only if the track object is down, if it's not down then the timer should simply  reset back and start counting down.

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

In this case, you should probably just use the watchdog timer event, and add a track read action and actions to test to see if it's down:

track read 3

if $_track_state eq "down"

 reload

end

event manager applet Shut-NoShut
 event track 3 state down
 action 1.0 cli command "en"
 action 2.0 cli command "conf t"
 action 3.0 cli command "interface di0"
 action 4.0 cli command "shut"
 action 5.0 cli command "no shut"
 action 6.0 wait 10
 action 7.0 cli command "event manager applet Reload-Applet"
 action 8.0 cli command "event track 3 state down"
 action 8.1 syslog msg "we are here"
 action 8.2 cli command "action 1 reload"
 action 9.0 cli command "end"
 action 9.1 cli command "write memory"
 action 9.3 cli command "end"
event manager applet Reload-Applet
 event track 3 state down
 action 1 reload

Now the "event manager applet Reload-Applet" accepts the reload action,
however after shutting and no shutting it's not reloading the router?

When you say read the track - how do you suggest I do that.

track read 3 is not a valid command under (config-applet)

I can check if $_track_state eq "down"  - NO issues here.

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

track read is an action, just like "if" and "cli".  You need to precede "track read" with action and a label.

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:

Recognize Your Peers