Hello everyone,
I am helping an NGO in India at the moment, where I set up an SXT LTE (RBSXTR) to get Internet in a remote area.
For the last few weeks my PCQ Queues are really messing up my router.
If the PCQ is enabled and any kind of load is applied - like even if there is only one User connected and starts a big download - it causes many router disconnects. F.e. like this:
Ping statistics for 192.168.86.1:
Packets: Sent = 64, Received = 27, Lost = 37 (57% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 2936ms, Average = 334ms
I am disconnected constantly from winbox, users cannot even load simple webpages, etc.
The PCQ shows about 10% packet drop, but not he LTE1 which is fine.
As soon as I disable the entire PCQ Queue, the Ping and the router behaves normally again (But the data on the SIM will be gone in no time).
Here is the PCQ setup:
/queue type add kind=pcq name=PCQ_download pcq-burst-rate=1150k pcq-burst-threshold=650k pcq-classifier=dst-address pcq-limit=80KiB pcq-rate=850 pcq-total-limit=6000KiB
/queue type add kind=pcq name=PCQ_upload pcq-burst-rate=1050k pcq-burst-threshold=650k pcq-classifier=src-address pcq-limit=80KiB pcq-rate=700k pcq-total-limit=4000KiB
/queue simple add max-limit=6M/6M name=PCQ-Queue queue=PCQ_upload/PCQ_download target=192.168.86.0/24,192.168.87.0/24 total-queue=default
I tried varying the pcq-limits but that brought no results.
Here is my complete public setup:
# jan/22/2020 20:27:42 by RouterOS 6.47beta19
# model = RBSXTR
/interface bridge add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no comment=defconf name=bridge
/interface ethernet set [ find default-name=ether1 ] l2mtu=1578 mtu=1480
/interface ethernet set [ find default-name=ether2 ] advertise=10M-half,10M-full,100M-half,100M-full,1000M-half,1000M-full
/interface list add comment=defconf name=WAN
/interface list add comment=defconf name=LAN
/interface wireless security-profiles set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile set [ find default=yes ] html-directory=flash/hotspot
/ip kid-control add fri=0s-23h59m mon=0s-23h59m name=Neil sat=0s-23h59m sun=0s-23h59m thu=0s-23h59m tue=0s-23h59m wed=0s-23h59m
/ip kid-control add fri=0s-23h59m mon=0s-23h59m name=Roman sat=0s-23h59m sun=0s-23h59m thu=0s-23h59m tue=0s-23h59m wed=0s-23h59m
/ip kid-control add fri=0s-23h59m mon=0s-23h59m name=Levente sat=0s-23h59m sun=0s-23h59m thu=0s-23h59m tue=0s-23h59m wed=0s-23h59m
/ip pool add name=dhcp ranges=192.168.86.100-192.168.86.254
/ip dhcp-server add add-arp=yes address-pool=dhcp bootp-support=dynamic disabled=no interface=bridge lease-script=UserCount lease-time=3m name=defconf
/queue type add kind=pcq name=PCQ_download pcq-burst-rate=1150k pcq-burst-threshold=650k pcq-classifier=dst-address pcq-limit=80KiB pcq-rate=850 pcq-total-limit=6000KiB
/queue type add kind=pcq name=PCQ_upload pcq-burst-rate=1050k pcq-burst-threshold=650k pcq-classifier=src-address pcq-limit=80KiB pcq-rate=700k pcq-total-limit=4000KiB
/queue simple add max-limit=6M/6M name=PCQ-Queue queue=PCQ_upload/PCQ_download target=192.168.86.0/24,192.168.87.0/24 total-queue=default
/user group add name=Users1 policy=local,telnet,ssh,reboot,read,write,test,winbox,web,api,romon,!ftp,!policy,!password,!sniff,!sensitive,!dude,!tikapp
/interface lte set [ find ] allow-roaming=yes apn-profiles=JioNet mac-address=AC:FF:FF:00:00:00 name=lte1 network-mode=lte
/interface bridge port add bridge=bridge comment=defconf interface=ether1
/interface bridge port add bridge=bridge comment=defconf disabled=yes interface=ether2
/ip neighbor discovery-settings set discover-interface-list=LAN
/interface detect-internet set detect-interface-list=all
/interface list member add comment=defconf interface=bridge list=LAN
/interface list member add comment=defconf interface=lte1 list=WAN
/interface lte apn add apn=JioNet ip-type=ipv4-ipv6 ipv6-interface=lte1
/ip accounting set threshold=8192
/ip accounting web-access set address=192.168.84.210/32
/ip address add address=192.168.86.1/24 comment=defconf interface=ether1 network=192.168.86.0
/ip cloud set ddns-enabled=yes
/ip dhcp-server alert add disabled=no interface=ether1 valid-server=B8:69:F4:05:D6:15
/ip dhcp-server lease add address=192.168.86.223 client-id=1:0:21:cc:da:4f:a mac-address=XX:XX:XX:XX:XX:XX server=defconf
/ip dhcp-server lease add address=192.168.86.221 client-id=1:80:fa:5b:15:2f:b comment=Levente mac-address=XX:XX:XX:XX:XX:XX server=defconf
/ip dhcp-server lease add address=192.168.86.220 client-id=1:58:ef:68:7e:32:71 comment=Neil mac-address=XX:XX:XX:XX:XX:XX server=defconf
/ip dhcp-server lease add address=192.168.86.217 client-id=1:0:26:9e:9f:bc:ad comment=Roman mac-address=XX:XX:XX:XX:XX:XX server=defconf
/ip dhcp-server network add address=192.168.86.0/24 comment=defconf dns-server=192.168.86.1,1.1.1.1 gateway=192.168.86.1 netmask=24
/ip dns set allow-remote-requests=yes servers=1.1.1.1,8.8.8.8
/ip dns static add address=192.168.86.1 name=router.lan
/ip firewall filter add action=accept chain=input comment="Accept Winbox" disabled=yes dst-port=8291 in-interface=lte1 protocol=tcp
/ip firewall filter add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
/ip firewall filter add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
/ip firewall filter add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
/ip firewall filter add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN
/ip firewall filter add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
/ip firewall filter add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
/ip firewall filter add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related disabled=yes
/ip firewall filter add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
/ip firewall filter add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
/ip firewall filter add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN
/ip firewall mangle add action=change-ttl chain=postrouting new-ttl=set:64 out-interface=lte1 passthrough=no
/ip firewall nat add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN
/ip kid-control device add mac-address=XX:XX:XX:XX:XX:XX name="Neil1" user=Neil
/ip kid-control device add mac-address=XX:XX:XX:XX:XX:XX name=Levente user=Levente
/ip kid-control device add mac-address=XX:XX:XX:XX:XX:XX name="Roman's PC" user=Roman
/ip kid-control device add mac-address=XX:XX:XX:XX:XX:XX name="Neil2" user=Neil
/ip kid-control device add mac-address=XX:XX:XX:XX:XX:XX name="Levente TL-WR802N" user=Levente
/ip ssh set forwarding-enabled=remote strong-crypto=yes
/system clock set time-zone-name=Asia/Kolkata
/system identity set name="SXT LTE"
/system leds
# using RSRP, modem-signal-treshold ignored
set 0 interface=lte1
/system logging set 1 action=disk
/system logging set 2 action=disk
/system logging add action=disk topics=critical
/system logging add action=echo topics=warning
/system logging add action=echo topics=error
/system logging add topics=lte,!raw,!info,!async
/system note set note="################## SYTEM STATUS ##################\
\nRouter: SXT LTE | Active b JioDoug7693\
\nTime: 20:26:29 | Uptime-hrs: 19:56:21 | CPU: 16%\
\nRAM Used/Total: 29/64M | Voltage: v | Temp: c\
\nHotspot online: 0 | PPP online: 0 | User online: 6\
\n###################################################\
\n"
/system package update set channel=testing
/system routerboard modem set sim-slot=b
/system scheduler add comment="StartUp with SIM B - Lower Slot" name="Start with SIM2B" on-event=StartUpSimB policy=reboot,read,write,policy,test,romon start-time=startup
/system scheduler add comment="Switch SIM 2 B LowerSlot at 12.30am" disabled=yes interval=1d name=SwitchSIM2B-LowerSlot on-event=SwitchSIM2-B-Script policy=reboot,read,write,policy,test,romon start-date=nov/12/2018 start-time=00:30:00
/system scheduler add comment="Switch to SIMA by Schedule at 17:30" interval=1d name=Switch2SIMA on-event=Switch2SIMA policy=reboot,read,write,policy,test start-date=dec/28/2018 start-time=17:30:00
/system scheduler add comment="Reboot at 12.30am" interval=1d name=Reboot on-event=Reboot policy=ftp,reboot,read,write,test,romon start-date=nov/12/2018 start-time=00:30:00
/system scheduler add disabled=yes interval=1d name="Reset Modem" on-event="Reset Modem" policy=reboot,read,write,test,romon start-date=jan/14/2019 start-time=12:00:00
/system scheduler add comment="Checks If Ether1 Is Down then TURNS OFF LTE" interval=1m30s name=TurnOffLTE on-event=TurnOffLTE policy=reboot,read,write,policy,test start-date=jan/17/2019 start-time=22:56:27
/system scheduler add comment="Runs RouterHealth script and puts info in /System Note to show at LogIn" interval=5m name=RouterHealth on-event=RouterHealth policy=read,write,policy,test start-date=jan/17/2020 start-time=17:56:29
/system script add comment="DEPRECATED FOR REBOOT 12.30am - Reset & Switch SIM 2 B LowerSlot" dont-require-permissions=no name=SwitchSIM2-B-Script owner=Tonie policy=reboot,read,write,policy,test,romon source="#Resets data counters and netwatch for a new day also variables\r\
\n# Script checks first which SIM Slot is active, if it is \r\
\n# \"a\" UpperSlot it will switch to \"b\" LowerSlot\r\
\n# Then log descriptive warning\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch disable \$i };\r\
\n:local datum [/system clock get date];\r\
\n:local time [/system clock get time];\r\
\n:global ProvSIMB\r\
\n#Reset NWTries for NetWatch\r\
\n:global NWTries 0\r\
\n:log warning \"RESETTING NWTries to ZERO for NETWATCH TO WORK AFRESH\"\r\
\n#Reset kid-control data useage counters\r\
\n:log warning \"RESETTING KID-CONTROL COUNTER STATS\"\r\
\n/ip kid-control device reset-counters\r\
\n:global simSlot [/system routerboard modem get sim-slot]\r\
\n# Check which SIM slot is used\r\
\n:if (\$simSlot=\"a\") do={\r\
\n# If \"a\" UpperSlot, switch to \"b\" LowerSlot\r\
\n/system routerboard modem set sim-slot=b\r\
\n:log warning \"SWITCHED TO SIM B LowerSlot - \$ProvSIMB BY SCRIPT-SCHEDULER at \$time \$datum\";\r\
\n:delay 90s;\r\
\n} else={\r\
\n:log warning \"SCRIPT-SCHEDULER AT \$time \$datum - SIMB \$ProvSIMB WAS ACTIVE\";\r\
\n}\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i };"
/system script add comment="NetWatch if SIM is down Switch to Other SIM" dont-require-permissions=yes name=NetWatchSwitch2OtherSIMSlot owner=Tonie policy=reboot,read,write,policy,test,romon source="#Needs dont-require-permissions=yes since otherwise it iinherits lower permissions from NetWatch\r\
\n:global NWTries\r\
\n:global Startup\r\
\n:global ProvSIMA\r\
\n:global ProvSIMB\r\
\n:if (\$Startup=\"Finished\") do={\r\
\n# Script checks first which SIM Slot is active, then\r\
\n# switches from active to inactive SIM Slot\r\
\n# Then log descriptive warning\r\
\n:global simSlot [/system routerboard modem get sim-slot]\r\
\n# Check which SIM slot is used\r\
\n:set \$NWTries (\$NWTries+1)\r\
\n:local time [/system clock get time];\r\
\n:log warning message=\"NETWATCH CANNOT PING 9999 ON SIM \$simSlot RUN NR. \$NWTries AT \$time\"\r\
\n{\r\
\nif (\$NWTries < 6) do={\r\
\n:if (\$simSlot=\"a\") do={\r\
\n# If \"a\" UpperSlot, switch to \"b\"\r\
\n/system routerboard modem set sim-slot=b\r\
\n:global ActiveSIM \$ProvSIMB\r\
\n:log warning \"NETWATCH SWITCHED TO SIM B - \$ProvSIMB AT \$time\"\r\
\n} else={\r\
\n# If \"b\" LowerSlot, switch to \"a\" UpperSlot\r\
\n/system routerboard modem set sim-slot=a\r\
\n:global ActiveSIM \$ProvSIMA\r\
\n:log warning \"NETWATCH SWITCHED TO SIM A - \$ProvSIMA AT \$time\"\r\
\n}\r\
\n} else={:log warning \"NETWATCH LOOP >5x - MODEM RESET SIM \$simSlot - NO SWITCH AT \$time!!!\";\r\
\n/interface lte at-chat lte1 input=\"AT+reset\"\r\
\n}\r\
\n}\r\
\n}"
/system script add comment="Binary/Script Backup Configuration" dont-require-permissions=yes name=BackupCfg owner=Tonie policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/system backup save\r\
\n:local date [/system clock get date];\r\
\n:local months {\"jan\"=\"01\";\"feb\"=\"02\";\"mar\"=\"03\";\"apr\"=\"04\";\"may\"=\"05\";\"jun\"=\"06\";\"jul\"=\"07\";\"aug\"=\"08\";\"sep\"=\"09\";\"oct\"=10;\"nov\"=11;\"dec\"=12};\r\
\n:local day [:tonum [:pick \$date 4 6]];\r\
\n:local year [:tonum [:pick \$date 7 11]];\r\
\n:local month [:pick \$date 0 3];\r\
\n:local mm (:\$months->\$month);\r\
\n:local newdate \"\$year\$mm\$day\";\r\
\n:local ctime [/system clock get time];\r\
\n:local mins [:pick \$ctime 3 5];\r\
\n:local hr [:pick \$ctime 0 2];\r\
\n/export terse compact file=([/system identity get value-name=name].\"-\".\$newdate.\"-\".\$hr.\$mins.\"-backup-cmp-prv.rsc\")\r\
\n/export terse verbose file=([/system identity get value-name=name].\"-\".\$newdate.\"-\".\$hr.\$mins.\"-backup-vrb-prv.rsc\")\r\
\n#For posting in forums for troubleshooting:\r\
\n/export terse compact hide-sensitive file=([/system identity get value-name=name].\"-\".\$newdate.\"-\".\$hr.\$mins.\"-backup-cmp-pub.rsc\")\r\
\n/export terse verbose hide-sensitive file=([/system identity get value-name=name].\"-\".\$newdate.\"-\".\$hr.\$mins.\"-backup-vrb-pub.rsc\")\r\
\n"
/system script add comment="Switch to Other SIM" dont-require-permissions=yes name=Switch2OtherSIM owner=Tonie policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#Switch2OtherSIM Script checks first which SIM Slot is active, then\r\
\n# switches from active to inactive SIM Slot\r\
\n# Then log descriptive warning\r\
\n:local simSlot\r\
\n:global ActiveSIM\r\
\n:global ProvSIMA\r\
\n:global ProvSIMB\r\
\n:local simSlot [/system routerboard modem get sim-slot]\r\
\n:local time [/system clock get time];\r\
\n# Check which SIM slot is used\r\
\n{\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch disable \$i };\r\
\n:if (\$simSlot=\"a\") do={\r\
\n# If \"a\" UpperSlot, switch to \"b\" LowerSlot\r\
\n/system routerboard modem set sim-slot=b\r\
\n:global ActiveSIM (\"SIM B\".\" \".\$ProvSIMB)\r\
\n:log warning \"SWITCHED TO SIM B - \$ProvSIMB BY SCRIPT at \$time\";\r\
\n:delay 120s;\r\
\n:local simSlot [/system routerboard modem get sim-slot]\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i };\r\
\n} else={\r\
\n# If \"b\" LowerSlot, switch to \"a\" UpperSlot\r\
\n/system routerboard modem set sim-slot=a\r\
\n:global ActiveSIM (\"SIM A\".\" \".\$ProvSIMA)\r\
\n:log warning \"SWITCHED TO SIM A - \$ProvSIMA BY SCRIPT at :\$time\";\r\
\n:delay 120s;\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i };\r\
\n}\r\
\n}\r\
\n"
/system script add comment="Reboot (Scheduler at 00:30)" dont-require-permissions=yes name=Reboot owner=Tonie policy=reboot,read,write,romon source=":local datum [/system clock get date];\r\
\n:local time [/system clock get time];\r\
\n:log warning message=\"REBOOT BY REBOOT SCRIPT ON \$datum AT \$time\";\r\
\n/system reboot;"
/system script add comment="TERMINAL RUN ONLY: /sys scr run AirtelBalance; \"Send/Receive USSD codes for Data Balance on Airtel\"" dont-require-permissions=no name=AirtelBalance owner=Tonie policy=read source="# Run this script in Terminal like this (copy/paste next line without #:\r\
\n# /system script run AirtelBalance\r\
\n# Copy text from last +CUSD: 1,\" results without quotes to:\r\
\n# http://www.unit-conversion.info/texttools/hexadecimal/#data\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch disable \$i };\r\
\n/interface lte set [ find ] name=lte1 network-mode=gsm,3g,lte\r\
\n:delay 20s\r\
\n/interface lte at-chat lte1 input=\"AT+CUSD=1,\\\"*121*2#\\\",15\"\r\
\n:put \"Waiting 20 Seconds... \"\r\
\n:delay 20s\r\
\n/log print where message~\"CUSD:\"\r\
\n:put \"INSTRUCTIONS: Copy text after last entry: +CUSD: 1,\" \r\
\n:put \"Then paste the text inside the quotes to: \"\r\
\n:put \"http://www.unit-conversion.info/texttools/hexadecimal/#data\"\r\
\n:put \"The number after Data: is still available, f.e. Data:266.5MB\"\r\
\n:put \"No Data line shown means no Data left.\"\r\
\n/interface lte set [ find ] name=lte1 network-mode=lte\r\
\n:delay 100s\r\
\n:execute {:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i };}"
/system script add comment="TERMINAL RUN ONLY: /sys scr run IdeaData" dont-require-permissions=no name=IdeaData owner=Tonie policy=read source="#Disabling Netwatch so it won't disturb\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch disable \$i };\r\
\n# Clearing SMS Inbox\r\
\n/tool sms inbox remove [/tool sms inbox find]\r\
\n# Sending USSD code *191*1#\r\
\n/interface lte at-chat lte1 input=\"AT+CUSD=1,\\\"*191*1#\\\",15\"\r\
\n:put \"Waiting 70 Sec for 3 SMS to arrive...\"\r\
\n:delay 70s\r\
\n/tool sms inbox print without-paging\r\
\n:put \"INSTRUCTIONS: Idea has several data packages on the same SIM - Data numbers after \\\"Bal:\\\" for all must be added up!\";\r\
\n#Resetting to lte and then back to 3g,lte to connect as LTE again\r\
\n/interface lte set lte1 network-mode=lte\r\
\n:delay 20s\r\
\n/interface lte set lte1 network-mode=3g,lte\r\
\n:delay 90s\r\
\n#Reenabling Netwatch\r\
\n:execute {:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i };}\r\
\n"
/system script add comment="Startup Script" dont-require-permissions=no name=StartUpSimB owner=Tonie policy=reboot,read,write,policy,test source="# StartUp Script for SXT LTE - Start Router with Sim b active\r\
\n:local simSlot\r\
\n:global ActiveUsers\r\
\n:global ActiveSIM\r\
\n:global ProvSIMA JioAmrita5165\r\
\n:global ProvSIMB JioDoug7693\r\
\n:global TimeUpdate\r\
\n:global DateUpdate\r\
\n# Startup Finished is checked by Netwatch script before proceeding, but is now redundant with extra checks for TurnOffLTE\r\
\n# Still leaving it in right for now to visually check Startup Finished\r\
\n:global Startup 0\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch disable \$i };\r\
\n# Script checks first which SIM Slot is active, if it is\r\
\n# \"a\" UpperSlot it will switch to \"b\" LowerSlot\r\
\n# Then log descriptive warning\r\
\n#At the end it will force time update and show corrected time\r\
\n:local simSlot [/system routerboard modem get sim-slot]\r\
\n:local datum [/system clock get date];\r\
\n:local time [/system clock get time];\r\
\n:log warning \"RUNNING STARTUP SCRIPT - ACTIVE SIM \$simSlot at \$time \$datum\"\r\
\n# Check which SIM slot is used\r\
\n:if (\$simSlot=\"a\") do={\r\
\n# If \"a\" UpperSlot, switch to \"b\" LowerSlot\r\
\n/system routerboard modem set sim-slot=b\r\
\n:local BOOTtime [/system clock get time];\r\
\n:local BOOTdatum [/system clock get date]\r\
\n:delay 90s\r\
\n/ip cloud force-update\r\
\n:delay 10s\r\
\n# Startup Finished is checked by Netwatch script before proceeding, but is now redundant with extra checks for TurnOffLTE\r\
\n:global Startup Finished\r\
\n:local time [/system clock get time];\r\
\n:local datum [/system clock get date];\r\
\n:global TimeUpdate (\$BOOTtime.\" > \".\$time)\r\
\n:global DateUpdate (\$BOOTdatum.\">\".\$datum)\r\
\n:global ActiveSIM (\"SIM B\".\" \".\$ProvSIMB)\r\
\n:log warning \"SWITCHED TO SIM B - \$ProvSIMB LowerSlot BY STARTUP SCRIPT at \$time \$datum\"\r\
\n:log warning \"IP-CLOUD UPDATED \$BOOTtime +100sec TO \$time + \$BOOTdatum TO \$datum\"\r\
\n#In case SimpleQueue was manually disabled, reenable it.\r\
\n/queue simple set [ find name=PCQ-Queue ] disabled=no;\r\
\n#Only reenable Netwatch if ether1 is up to avoid conflict with TurnOffLTE script \r\
\n:if ( [/interface ethernet get value-name=running ether1 ] = true ) do={\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i }};\r\
\n} else={\r\
\n:global ActiveSIM (\"SIM B\".\" \".\$ProvSIMB)\r\
\n:log warning \"STARTUP SCRIPT FINISHED AT \$time ON \$datum - SIM B \$ProvSIMB LowerSlot WAS ALREADY ACTIVE\"\r\
\n:local BOOTtime [/system clock get time];\r\
\n:local BOOTdatum [/system clock get date];\r\
\n:delay 90s\r\
\n/ip cloud force-update\r\
\n:delay 10s\r\
\n:local time [/system clock get time];\r\
\n:local datum [/system clock get date];\r\
\n:global TimeUpdate (\$BOOTtime.\" > \".\$time)\r\
\n:global DateUpdate (\$BOOTdatum.\">\".\$datum)\r\
\n:log warning \"IP-CLOUD UPDATED \$BOOTtime +100sec TO \$time + \$BOOTdatum TO \$datum\"\r\
\n#In case SimpleQueue was manually disabled, reenable it.\r\
\n/queue simple set [ find name=PCQ-Queue ] disabled=no;\r\
\n# Startup Finished is checked by Netwatch script before proceeding, but is now redundant with extra checks for TurnOffLTE\r\
\n:global Startup Finished\r\
\n#Only reenable Netwatch if ether1 is up to avoid conflict with TurnOffLTE script\r\
\n:if ( [/interface ethernet get value-name=running ether1 ] = true ) do={\r\
\n#Due to bug in DHCP Server Lease Script (verified at least since 6.47beta19) Lease Script does not count 1st bound lease - therefore adding 1st user to variable ActiveUsers\r\
\n#:global ActiveUsers 1\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i }};\r\
\n}"
/system script add dont-require-permissions=no name="Resetting Counters MTA2 #13" owner=Tonie policy=read,write,policy,test,romon source="#/ip kid-control device reset-counters\r\
\n#To reset only a specific device in Kid Control, use the number for the device, f.e. MTA2 is 13, so this would be\r\
\n/ip kid-control device reset-counters 13"
/system script add comment="Resetting Mobile Connection Safely" dont-require-permissions=no name="Reset Modem" owner=Tonie policy=reboot,read,write,test,romon source=":foreach i in= [ /tool netwatch find ] do={ :tool netwatch disable \$i };\r\
\n/interface lte at-chat lte1 input=\"AT+reset\";\r\
\n:local time [/system clock get time];\r\
\n:log warning message=\"RESETTING MODEM BY SCRIPT AT \$time - NO SIM SWITCH\";\r\
\n:delay 99s\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i }\r\
\n"
/system script add comment="Switch to SIMA UpperSlot by Schedule at 17:30" dont-require-permissions=no name=Switch2SIMA owner=Tonie policy=reboot,read,write,policy,test source="# Switch2SIMA Script switches to SIM Slot A\r\
\n# Then log descriptive warning\r\
\n:local time\r\
\n:local simSlot\r\
\n:global ProvSIMA\r\
\n:global ActiveSIM\r\
\n:local simSlot [/system routerboard modem get sim-slot]\r\
\n:local time [/system clock get time];\r\
\n# Check which SIM slot is used\r\
\n{\r\
\n:if (\$simSlot=\"b\") do={\r\
\n# First Disable NetWatch\r\
\n:foreach i in= [ /tool netwatch find ] do={ \r\
\n:tool netwatch disable \$i};\r\
\n:delay 2s;\r\
\n# If \"b\" LowerSlot, switch to \"a\" UpperSlot\r\
\n/system routerboard modem set sim-slot=a\r\
\n:log warning \"SWITCHED TO SIM A - \$ProvSIMA BY SCRIPT at \$time\";\r\
\n:global ActiveSIM (\"SIM A\".\" \".\$ProvSIMA)\r\
\n:delay 90s;\r\
\n# Enable NetWatch again\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i };\r\
\n} else={\r\
\n:log warning \"SIM A \$ProvSIMA WAS ACTIVE - NO CHANGES BY SCRIPT at \$time\";\r\
\n:global ActiveSIM (\"SIM A\".\" \".\$ProvSIMA)\r\
\n}\r\
\n}"
/system script add comment="Checks If Ether1 Is Down then TURNS OFF LTE" dont-require-permissions=no name=TurnOffLTE owner=Tonie policy=reboot,read,write,policy,test source="# TurnOffLTE script monitors states of Ether1 and LTE1 and executes actions for each combined state\r\
\n{\r\
\n:local time [/system clock get time];\r\
\n:if ( ([/interface ethernet get value-name=running ether1 ] = false) and ([/interface lte get lte1 disabled ] = true)) do={\r\
\n:local time [/system clock get time]\r\
\n# Using Eth1Lte1BothDown variable to have only one log warning when ETHER1 and LTE1 are down simultaneously\r\
\n:global Eth1Lte1BothDown\r\
\n:if ( \$Eth1Lte1BothDown !=\"Yes\") do={\r\
\n/log warning \"ETHER1 and LTE1 BOTH DOWN at \$time - Script does nothing\"\r\
\n:global Eth1Lte1BothDown \"Yes\"\r\
\n# No Router Status needs to be updated in /system note\r\
\n/system scheduler disable RouterHealth\r\
\n}\r\
\n} else={\r\
\n# Clear variable Eth1Lte1BothDown if it was set on a previous run\r\
\n:global Eth1Lte1BothDown \"\"\r\
\n:if ( [/interface ethernet get value-name=running ether1 ] = false ) do={\r\
\n#Script decided: ether1 down, but lte1 up\r\
\n#NETWATCH needs disabling only when lte1 gets disabled\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch disable \$i };\r\
\n[/log warning \"ETHER1 NOT RUNNING - DISABLING LTE1 AT \$time\"] and [:interface lte disable lte1 ];\r\
\n# No Router Status needs to be updated in /system note\r\
\n/system scheduler disable RouterHealth\r\
\n} else={\r\
\n:if ([/interface lte get lte1 disabled ] = true) do={\r\
\n#Script decided: ether1 now connected, lte1 down\r\
\n[:interface lte enable lte1 ] and \r\
\n[/log warning \"Ether1 Is Up - REENABLING LTE1 AT \$time\"]\r\
\n###In case SimpleQueue was manually disabled, reenable it.\r\
\n### (DISABLED FOR TEST with UserCount)/queue simple set [ find name=PCQ-Queue ] disabled=no;\r\
\n###Due to bug in DHCP Server Lease Script (verified at least since 6.47beta19) Lease Script does not count 1st bound lease - therefore adding 1st user to variable ActiveUsers\r\
\n### (DISABLED FOR TEST):global ActiveUsers 1\r\
\n# Router Status needs to be updated in /system note\r\
\n/system scheduler enable RouterHealth\r\
\n:delay 120s;\r\
\n#NETWATCH must be ENABLED only after lte1 gets enabled\r\
\n:foreach i in= [ /tool netwatch find ] do={ :tool netwatch enable \$i };\r\
\n}\r\
\n#Else Not Necessary - no action [/log info \"ETHER1 and LTE1 UP at \$time - Script does nothing\"]\r\
\n}\r\
\n}\r\
\n}"
/system script add comment="puts Health etc info in /System Note to show at LogIn" dont-require-permissions=no name=RouterHealth owner=Tonie policy=read,write,policy,test source=":local content\r\
\n:local logcontenttemp \"\"\r\
\n:local logcontent \"\"\r\
\n:local counter\r\
\n:local v 0\r\
\n:local Nowtime [/system clock get time]\r\
\n:global ActiveSIM\r\
\n:global ActiveUsers\r\
\n \r\
\n:set logcontenttemp \"################## SYTEM STATUS ##################\"\r\
\n:set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\"\\n\")\r\
\n \r\
\n:set logcontenttemp \"Router: \$[/system identity get name] | Active \$ActiveSIM\"\r\
\n:set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\"\\n\")\r\
\n \r\
\n:set logcontenttemp \"Time: \$[/system clock get time] | Uptime-hrs: \$[/system resource get uptime]\"\r\
\n:set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\" | \")\r\
\n \r\
\n:set logcontenttemp \"CPU: \$[/system resource get cpu-load]%\"\r\
\n:set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\"\\n\")\r\
\n \r\
\n:set logcontenttemp \"RAM Used/Total: \$((([/system resource get total-memory]-[/system resource get free-memory])/1024)/1024)/\$(([/system resource get total-memory]/1024)/1024)M\"\r\
\n:set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\" | \")\r\
\n \r\
\n##\r\
\n#voltage and temp readout not available on x86, check for this before trying\r\
\n#to record otherwise script will halt unexpectedly\r\
\n##\r\
\n \r\
\n:if ([/system resource get architecture-name]=\"x86\") do={\r\
\n :set logcontenttemp \"Voltage: NIL\"\r\
\n :set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\" | \")\r\
\n :set logcontenttemp \"Temp: NIL\"\r\
\n :set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\"\\n\")\r\
\n} else={\r\
\n :set logcontenttemp \"Voltage: \$[:pick [/system health get voltage] 0 2] v\"\r\
\n :set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\" | \")\r\
\n :set logcontenttemp \"Temp: \$[ /system health get temperature]c\"\r\
\n :set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\"\\n\")\r\
\n}\r\
\n \r\
\n:foreach counter in=[/ip hotspot active find ] do={:set v (\$v + 1)}\r\
\n:set logcontenttemp \"Hotspot online: \$v |\"\r\
\n:set v 0\r\
\n:foreach counter in=[/ppp active find ] do={:set v (\$v + 1)}\r\
\n:set logcontenttemp (\"\$logcontenttemp\" . \" PPP online: \$v |\")\r\
\n:set v 0\r\
\n:set v \$ActiveUsers\r\
\n:set logcontenttemp (\"\$logcontenttemp\" . \" User online: \$v\")\r\
\n:set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\"\\n\")\r\
\n:set logcontenttemp \"###################################################\"\r\
\n:set logcontent (\"\$logcontent\" .\"\$logcontenttemp\" .\"\\n\")\r\
\n \r\
\n/system note set note=\"\$logcontent\""
/system script add comment="DHCPLease Script for UserCount" dont-require-permissions=no name=UserCount owner=Tonie policy=read,write,policy,test source="#UserCount is DHCP Server Lease Script entry to show ActiveUsers by counting bound leases\r\
\n#Due to bug in DHCP Server Lease Script (verified at least since 6.47beta19) Lease Script does not count 1st bound lease - therefore StartUpSimB and TurnOffLTE scripts add 1st user to variable ActiveUsers in their relevant if statements\r\
\n####################\r\
\n:global ActiveUsers\r\
\n:if (\$leaseBound = \"1\") do={\r\
\n:set ActiveUsers (\$ActiveUsers + 1);\r\
\n} else={\r\
\n:set ActiveUsers (\$ActiveUsers - 1);\r\
\n}\r\
\n#Simple Queue Enable If More Than 1 User\r\
\nif (\$ActiveUsers >1) do={\r\
\n#In case SimpleQueue was manually disabled, reenable it.\r\
\n/queue simple set [ find name=PCQ-Queue ] disabled=no;\r\
\n}"
/tool bandwidth-server set enabled=no
/tool graphing interface add interface=lte1
/tool graphing queue add simple-queue=PCQ-Queue
/tool graphing resource add
/tool mac-server set allowed-interface-list=LAN
/tool mac-server mac-winbox set allowed-interface-list=LAN
/tool netwatch add down-script=NetWatchSwitch2OtherSIMSlot host=9.9.9.9
/tool romon set enabled=yes id=00:00:00:00:00:06
/tool sms set allowed-number=,,, port=lte1 receive-enabled=yes
/tool sniffer set filter-direction=tx filter-interface=lte1 filter-operator-between-entries=and
Hope someone can help. I am pulling my hair out!