cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
488
Views
0
Helpful
6
Replies

Cisco reload

gwijnants
Level 1
Level 1

Hi all,

I am looking for a solution (EEM applet, ...) that as long as a tracker remains down the router will reboot every 15 minutes.
Now the router reboots when the tracker is down (using EEM applet) but if after the reboot the tracker stays down the router does not reboot anymore.

Any ideas anyone?

Best Regards

1 Accepted Solution

Accepted Solutions

EEM is triggered when a tracked object changes state.  To monitor the tracker in EEM for changes after it is triggered then CLI comands need to be run to get the updated state of the tracker.  Track1 &2 have a delay of 180 seconds so EEM will not be triggered until ip sla is down for 3 minutes.  You may want to update the the reload to happen in 12 minutes so total downtime of ip sla is 15 minutes.   Here is an example of EEM policy to meet your requirements.

event manager applet reloadRouter
 event tag t1 track 3 state down maxrun 930
 event tag t2 timer cron cron-entry "@reboot"
 trigger
  correlate event t1 or event t2
 action 010 cli command "enable"
 action 080 set loop "0"
 action 090 while $loop le 50
 action 100  cli command "show track 3 | inc Reachability"
 action 110  regexp "Reachability is ([a-zA-Z]+)" "$_cli_result" match state
 action 120  if $state eq "Down"
 action 130   if $loop eq "0"
 action 135    cli command "wr"
 action 140    cli command "reload in 15" pattern "[confirm]"
 action 145    cli command ""
 action 150   end
 action 160   increment loop 1
 action 170   puts "track is $state waiting 30 seconds. loop = $loop"
 action 180   wait 30
 action 190  elseif $state eq Up
 action 195   puts "Track 3 is back up.  Canceling reload"
 action 200   cli command "reload cancel"
 action 210   exit 1
 action 220  end
 action 230 end
!

test

*Jun  1 20:44:49.408: %TRACK-6-STATE: 3 ip sla 3 reachability Up -> Down
*Jun  1 20:45:00.451: %SYS-6-PRIVCFG_ENCRYPT_SUCCESS: Successfully encrypted private config file
*Jun  1 20:45:00.993: %SYS-5-SCHEDULED_RELOAD: Reload requested for 21:00:00 UTC Sat Jun 1 2024 at 20:45:00 UTC Sat Jun 1 2024 by  on vty0 (EEM:reloadRouter). Reload Reason: Reload Command.
*Jun  1 20:45:01.003: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 1
*Jun  1 20:45:31.119: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 2
*Jun  1 20:46:01.231: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 3
*Jun  1 20:46:31.343: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 4
*Jun  1 20:46:55.352: %TRACK-6-STATE: 3 ip sla 3 reachability Down -> Up


***
*** --- SHUTDOWN ABORTED ---
***

*Jun  1 20:47:01.461: %HA_EM-6-LOG: reloadRouter: Track 3 is back up.  Canceling reload
*Jun  1 20:47:01.473: %SYS-5-SCHEDULED_RELOAD_CANCELLED:  Scheduled reload cancelled at 20:47:01 UTC Sat Jun 1 2024 

 

View solution in original post

6 Replies 6

What you want exactly that need reboot the router 

MHM

gwijnants
Level 1
Level 1

Basically if the internet link goes down on the router (tracker to 8.8.8.8 goes down) the router reboots (reload) in 15 minutes. if in the meantime the link is restored the reload gets cancelled. If the link is not restored the router reboots, after the reboot the process continues. Meaning still no link the router reboots again in 15 minutes, if the link is restored the reboot gets cancelled.

Hello,

it sounds like you currently already have an EEM script running, can you post that ?

ip sla 1
 icmp-echo 8.8.8.8 source-interface Cellular0/1/0
  threshold 1000
  timeout 2000
  frequency 5
ip sla schedule 1 life forever start-time now
ip sla 2
 icmp-echo 4.4.4.4 source-interface Cellular0/1/0
  threshold 1000
  timeout 2000
  frequency 5
ip sla schedule 2 life forever start-time now

track 1 ip sla 1 reachability
 delay down 180
track 2 ip sla 2 reachability
 delay down 180

track 3 list boolean or
 object 1
 object 2

event manager applet Reload-router
event track 3 state down
action 1.0 reload

Now if my cellular interface (4G) is down the router will reload. But I want it to keep reloading (every 15 minutes) as long as the 4G connection is not restored.

So my EEM script should be something like this

event manager applet Reload-router
event track 3 state down
action 1.0 reload in 15

event manager applet Reload-router-Stop
event track 3 state up
action 1.0 cancel reload

But after the first reload the router does not reload again when the 4G connection is not restored. 

EEM is triggered when a tracked object changes state.  To monitor the tracker in EEM for changes after it is triggered then CLI comands need to be run to get the updated state of the tracker.  Track1 &2 have a delay of 180 seconds so EEM will not be triggered until ip sla is down for 3 minutes.  You may want to update the the reload to happen in 12 minutes so total downtime of ip sla is 15 minutes.   Here is an example of EEM policy to meet your requirements.

event manager applet reloadRouter
 event tag t1 track 3 state down maxrun 930
 event tag t2 timer cron cron-entry "@reboot"
 trigger
  correlate event t1 or event t2
 action 010 cli command "enable"
 action 080 set loop "0"
 action 090 while $loop le 50
 action 100  cli command "show track 3 | inc Reachability"
 action 110  regexp "Reachability is ([a-zA-Z]+)" "$_cli_result" match state
 action 120  if $state eq "Down"
 action 130   if $loop eq "0"
 action 135    cli command "wr"
 action 140    cli command "reload in 15" pattern "[confirm]"
 action 145    cli command ""
 action 150   end
 action 160   increment loop 1
 action 170   puts "track is $state waiting 30 seconds. loop = $loop"
 action 180   wait 30
 action 190  elseif $state eq Up
 action 195   puts "Track 3 is back up.  Canceling reload"
 action 200   cli command "reload cancel"
 action 210   exit 1
 action 220  end
 action 230 end
!

test

*Jun  1 20:44:49.408: %TRACK-6-STATE: 3 ip sla 3 reachability Up -> Down
*Jun  1 20:45:00.451: %SYS-6-PRIVCFG_ENCRYPT_SUCCESS: Successfully encrypted private config file
*Jun  1 20:45:00.993: %SYS-5-SCHEDULED_RELOAD: Reload requested for 21:00:00 UTC Sat Jun 1 2024 at 20:45:00 UTC Sat Jun 1 2024 by  on vty0 (EEM:reloadRouter). Reload Reason: Reload Command.
*Jun  1 20:45:01.003: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 1
*Jun  1 20:45:31.119: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 2
*Jun  1 20:46:01.231: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 3
*Jun  1 20:46:31.343: %HA_EM-6-LOG: reloadRouter: track is Down waiting 30 seconds. loop = 4
*Jun  1 20:46:55.352: %TRACK-6-STATE: 3 ip sla 3 reachability Down -> Up


***
*** --- SHUTDOWN ABORTED ---
***

*Jun  1 20:47:01.461: %HA_EM-6-LOG: reloadRouter: Track 3 is back up.  Canceling reload
*Jun  1 20:47:01.473: %SYS-5-SCHEDULED_RELOAD_CANCELLED:  Scheduled reload cancelled at 20:47:01 UTC Sat Jun 1 2024 

 

Thank you for the response and solution! This works fine.