12-04-2023 04:33 AM
Hi
Every now and then we have a router that goes offline because of its 4G module.
What we do now is physically go to the router and put in a reload.
Is there a way to automatically restart only the 4G module whenever the router detects that it has no more 4G?
Solved! Go to Solution.
12-04-2023 11:05 AM
Hello,
the script needs a few changes (such as the maxrun timer, as by default it will run for 20 seconds). You also need to match on syslog pattern. You also need to get into 'enable' mode.
The below should work:
event manager applet restart_4g
event syslog pattern " %LINEPROTO-5-UPDOWN: Line protocol on Interface Cellular0/2/0, changed state to down" maxrun 180
action 1 cli command "enable"
action 2 wait 60
action 3 cli command "show interface Cellular0/2/0 | include line protocol"
action 4 regexp "line protocol is (\\w+)" "$_cli_result" match state
action 5 if $_regexp_result eq "up"
action 6 syslog msg "Cellular0/2/0 is back up, no action needed"
action 7 else
action 8 syslog msg "Cellular0/2/0 is still down, executing script"
action 9 cli command "config t"
action 9.1 cli command "interface Cellular0/2/0"
action 9.2 cli command "shut"
action 9.3 wait 5
action 9.4 cli command "no shutdown"
action 9.5 cli command "end"
action 9.6 syslog msg "Cellular0/2/0 has been restarted"
action 9.7 end
12-04-2023 05:02 AM
You need to provide some informatiom,what model of the router and what IOS code running to help better.
other suggestions : (users reported that below command fix the issue)
ROUTER# test cellular 0/2/0 modem-power-cycle
ROUTER# test cellular 0/2/0 modem-reset
You can also use EEM Script if the router not able to reach internet with ping and wait for 2 fails or 3 fails you can restart modem
12-04-2023 05:49 AM - edited 12-04-2023 06:19 AM
I wrote this real quick, we'll have to do some testing to see if it works correctly.
event manager applet restart_4g
event track 1 state down
action 1 syslog msg "Cellular0/2/0 is down, waiting for 60 seconds in case it comes back up"
action 2 wait 60
action 3 cli command "show interface Cellular0/2/0 | include line protocol"
action 4 regexp "line protocol is (\\w+)" "$_cli_result" match state
action 5 if $_regexp_result eq "up"
action 6 syslog msg "Cellular0/2/0 is back up, no action needed"
action 7 else
action 8 syslog msg "Cellular0/2/0 is still down, executing script"
action 9 cli command "config t"
action 10 cli command "interface ce0/2/0"
action 11 cli command "shut"
action 12 wait 5
action 13 cli command "no shutdown"
action 14 cli command "end"
action 15 syslog msg "Cellular0/2/0 has been restarted"
action 16 end
action 17 end
12-04-2023 09:31 AM - edited 12-04-2023 09:33 AM
Sure that is way to go, try manually that command works , then use EEM to automate.
EEM script, make sure your syslog message matched as you mentioned - may be not the case you get lot, you get only down log, so adjust based on the requirement.
12-04-2023 11:05 AM
Hello,
the script needs a few changes (such as the maxrun timer, as by default it will run for 20 seconds). You also need to match on syslog pattern. You also need to get into 'enable' mode.
The below should work:
event manager applet restart_4g
event syslog pattern " %LINEPROTO-5-UPDOWN: Line protocol on Interface Cellular0/2/0, changed state to down" maxrun 180
action 1 cli command "enable"
action 2 wait 60
action 3 cli command "show interface Cellular0/2/0 | include line protocol"
action 4 regexp "line protocol is (\\w+)" "$_cli_result" match state
action 5 if $_regexp_result eq "up"
action 6 syslog msg "Cellular0/2/0 is back up, no action needed"
action 7 else
action 8 syslog msg "Cellular0/2/0 is still down, executing script"
action 9 cli command "config t"
action 9.1 cli command "interface Cellular0/2/0"
action 9.2 cli command "shut"
action 9.3 wait 5
action 9.4 cli command "no shutdown"
action 9.5 cli command "end"
action 9.6 syslog msg "Cellular0/2/0 has been restarted"
action 9.7 end
12-05-2023 01:47 AM - edited 12-06-2023 09:39 AM
I've modified it a little more but this works!
event manager applet restart_4g
event syslog pattern " %LINEPROTO-5-UPDOWN: Line protocol on Interface Cellular0/2/0, changed state to down" maxrun 180
action 1.0 syslog msg "Cellular0/2/0 is down, waiting for 60 seconds in case it comes back up"
action 1.1 wait 60
action 2 cli command "enable"
action 3 cli command "show interface Cellular0/2/0 | include line protocol"
action 4 regexp "line protocol is (\\w+)" "$_cli_result" match state
action 5 if $state eq "up"
action 6 syslog msg "Cellular0/2/0 is back up, no action needed"
action 7 else
action 8 syslog msg "Cellular0/2/0 is still down, executing script"
action 9 cli command "config t"
action 9.1 cli command "interface Cellular0/2/0"
action 9.2 cli command "shut"
action 9.3 wait 5
action 9.4 cli command "no shutdown"
action 9.5 cli command "end"
action 9.6 syslog msg "Cellular0/2/0 has been restarted"
action 9.7 end
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide