| 1 | = Mikrotik = |
| 2 | |
| 3 | Script for checking Internet, VPN |
| 4 | |
| 5 | {{{ |
| 6 | #!sh |
| 7 | [admin@G01] > /system script print |
| 8 | Flags: I - invalid |
| 9 | 0 name="script_reboot" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
| 10 | dont-require-permissions=no last-started=feb/28/2021 16:13:33 run-count=30 |
| 11 | source= |
| 12 | :if ([/ping 8.8.8.8 count=3 size=64 interval=2s]=0) do={ |
| 13 | :log error "LTE DOWN"; |
| 14 | /system reboot; |
| 15 | } else={ |
| 16 | :log info "LTE OK"; |
| 17 | } |
| 18 | |
| 19 | 1 name="check_vpn" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon dont-require-permissions=no |
| 20 | last-started=feb/28/2021 16:22:33 run-count=15 source= |
| 21 | :if ([/ping 192.168.59.1 count=3 size=64 interval=2s]=0) do={ |
| 22 | :log error "----VPN DOWN"; |
| 23 | /interface pptp-client set pptp-out1 disabled=yes; |
| 24 | /delay 1s; |
| 25 | /interface pptp-client set pptp-out1 disabled=no; |
| 26 | } else={ |
| 27 | :log info "----VPN OK"; |
| 28 | } |
| 29 | |
| 30 | 2 name="check_internet" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
| 31 | dont-require-permissions=no last-started=feb/28/2021 16:23:33 run-count=29 |
| 32 | source= |
| 33 | :if ([/ping 8.8.8.8 count=3 size=64 interval=2s]=0) do={ |
| 34 | :log error "----Internet DOWN"; |
| 35 | /interface lte set numbers=lte1 disabled=yes; |
| 36 | /system routerboard usb power-reset duration=1; |
| 37 | :log info "---Power USB DOWN ---"; |
| 38 | /delay 40s; |
| 39 | /interface lte set numbers=lte1 disabled=no; |
| 40 | :log info "---Enable lte1 "; |
| 41 | } else={ |
| 42 | :log info "----Internet OK"; |
| 43 | } |
| 44 | |
| 45 | 3 name="vpn_lossLong" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
| 46 | dont-require-permissions=no run-count=0 source= |
| 47 | :if ([/ping 192.168.59.1 count=10 size=64 interval=5s]=0) do={ |
| 48 | :log error "----VPN LOSS LONG DOWN Reboot"; |
| 49 | /system reboot; |
| 50 | } else={ |
| 51 | :log info "----VPN LOSS LONG OK"; |
| 52 | } |
| 53 | [admin@G01] > |
| 54 | |
| 55 | }}} |
| 56 | |