I have a wAP running 7.16.1, qcom-ac, with interface "wifi2ghz" and a slave interface "2point4"
Three devices at approximately 150 meters connect to 2point4 (all Sonoff THR-316) and stay connected rock solid, with signal strength between -76 and -84.
Another device (Emporia Vue) at about 100 meters (but behind the wAP) tries to connect to wifi2ghz and continuously gets "connected" then "disconnected", even with signal strength around -70.
Code: Select all
16:21:16 wireless,info 84:0D:8E:38:C0:64@wifi2ghz disconnected, connection lost, signal strength -70
16:21:17 wireless,info 84:0D:8E:38:C0:64@wifi2ghz connected, signal strength -60
From what I can tell, wifi2ghz and 2point4 are set up identically.
Sounds like the problem is specific to the client, or client-AP pairing.
Here is the registration table for the 3 rock-solid connected devices:
Code: Select all
[admin@355wap-carport] /interface/wifi/registration-table> print brief
Flags: A - AUTHORIZED
Columns: INTERFACE, SSID, MAC-ADDRESS, UPTIME, SIGNAL
# INTERFACE SSID MAC-ADDRESS UPTIME SIGNAL
;;; Hoophouse 3
0 A 2point4 2point4 3C:E9:0E:89:EB:A4 11h1m54s -83
;;; Hoophouse 1
1 A 2point4 2point4 3C:E9:0E:8A:13:44 10h31m12s -76
;;; Hoophouse 2
2 A 2point4 2point4 C0:49:EF:F7:B9:F8 10h17m38s -81
Here is the wAP config:
Code: Select all
# 2024-11-17 16:28:50 by RouterOS 7.16.1
# software id = D04C-WYEI
#
# model = RBwAPG-5HacD2HnD
# serial number = HDA0
/interface bridge add admin-mac=18:FD:74:50:0F:CB auto-mac=no comment=defconf name=bridge port-cost-mode=short
/interface ethernet set [ find default-name=ether1 ] mac-address=18:FD:74:50:0F:CA
/interface ethernet set [ find default-name=ether2 ] mac-address=18:FD:74:50:0F:CB
/interface wifi set [ find default-name=wifi2 ] channel.band=5ghz-ac .frequency=5490-5570 .skip-dfs-channels=disabled .width=20/40/80mhz comment=wifi-5ghz configuration.country="United States" .mode=ap .ssid=Chickens-5ghz disabled=no name=wifi-5ghz security.authentication-types=wpa2-psk .passphrase=<password>1!
/interface wifi set [ find default-name=wifi1 ] channel.band=2ghz-n .frequency=2412 .skip-dfs-channels=disabled .width=20mhz comment=wifi2ghz configuration.country="United States" .mode=ap .ssid=Chickens disabled=no name=wifi2ghz security.authentication-types=wpa2-psk .passphrase=<password>1!
/interface wifi add comment=2point4 configuration.mode=ap .ssid=2point4 disabled=no mac-address=1A:FD:74:D7:58:38 master-interface=wifi2ghz name=2point4 security.authentication-types=wpa2-psk .passphrase=<password>1!
/interface list add comment=defconf name=WAN
/interface list add comment=defconf name=LAN
/interface lte apn set [ find default=yes ] ip-type=ipv4 use-network-apn=no
/ip pool add name=192.168.0.220-192.168.0.251 ranges=192.168.0.220-192.168.0.251
/ip dhcp-server add address-pool=192.168.0.220-192.168.0.251 interface=bridge lease-time=1h name=defconf
/ip smb users set [ find default=yes ] disabled=yes
/routing bgp template set default disabled=no output.network=bgp-networks
/routing ospf instance add disabled=no name=default-v2
/routing ospf area add disabled=yes instance=default-v2 name=backbone-v2
/system logging action set 3 remote=192.168.0.13
/system logging action add name=logserver remote=192.168.0.112 remote-port=51400 target=remote
/interface bridge filter add action=drop chain=forward disabled=yes ip-protocol=udp log=yes mac-protocol=ip src-address=0.0.0.0/0 src-port=67
/interface bridge port add bridge=bridge comment=defconf ingress-filtering=no interface=ether2 internal-path-cost=10 path-cost=10
/interface bridge port add bridge=bridge comment=defconf disabled=yes ingress-filtering=no interface=*3 internal-path-cost=10 learn=yes path-cost=10
/interface bridge port add bridge=bridge comment=defconf disabled=yes ingress-filtering=no interface=*4 internal-path-cost=10 path-cost=10
/interface bridge port add bridge=bridge ingress-filtering=no interface=ether1 internal-path-cost=10 path-cost=10
/interface bridge port add bridge=bridge disabled=yes ingress-filtering=no interface=*6 internal-path-cost=10 learn=yes path-cost=10
/interface bridge port add bridge=bridge interface=wifi-5ghz
/interface bridge port add bridge=bridge interface=wifi2ghz
/interface bridge port add bridge=bridge interface=2point4
/ip firewall connection tracking set udp-timeout=10s
/ip neighbor discovery-settings set discover-interface-list=all
/ip settings set max-neighbor-entries=8192
/ipv6 settings set disable-ipv6=yes max-neighbor-entries=8192
/interface list member add comment=defconf interface=bridge list=LAN
/interface list member add comment=defconf disabled=yes interface=ether1 list=WAN
/interface list member add interface=ether1 list=LAN
/interface ovpn-server server set auth=sha1,md5
/interface wifi access-list add action=accept comment="Hoophouse 3" disabled=no mac-address=3C:E9:0E:89:EB:A4
/interface wifi access-list add action=accept comment="Hoophouse 2" disabled=no mac-address=C0:49:EF:F7:B9:F8
/interface wifi access-list add action=accept comment="Diego's phone" disabled=no mac-address=2E:34:7B:25:BF:18
/interface wifi access-list add action=accept comment="Hoophouse 1" disabled=no mac-address=3C:E9:0E:8A:13:44
/interface wifi access-list add action=accept comment="Vue White" disabled=no mac-address=84:0D:8E:38:C0:64
/ip address add address=192.168.0.80/24 interface=bridge network=192.168.0.0
/ip cloud set ddns-enabled=yes
/ip dhcp-server lease add address=192.168.0.251 client-id=1:c0:49:ef:f7:b9:f8 comment="THR316 Hoophouse 1" mac-address=C0:49:EF:F7:B9:F8 server=defconf
/ip dhcp-server lease add address=192.168.0.249 comment="TH10 Hoophouse 1" mac-address=E8:DB:84:9D:BD:BE server=defconf
/ip dhcp-server lease add address=192.168.0.246 comment="Shelly Uni Hoophouse 1" mac-address=E8:68:E7:F4:6E:29 server=defconf
/ip dhcp-server lease add address=192.168.0.243 comment="Hoophouse Shelly Uni Tasmota 1" mac-address=C4:5B:BE:E2:0E:C0 server=defconf
/ip dhcp-server lease add address=192.168.0.250 comment="Emporia Vue" mac-address=10:52:1C:41:FA:A0 server=defconf
/ip dhcp-server lease add address=192.168.0.245 comment=tasmota-DED0DB-4315 mac-address=C4:5B:BE:DE:D0:DB server=defconf
/ip dhcp-server lease add address=192.168.0.244 comment=Flume-GW-B70E mac-address=48:55:19:65:B7:0E server=defconf
/ip dhcp-server lease add address=192.168.0.233 block-access=yes comment="Emporia Vue (probably White)" disabled=yes mac-address=84:0D:8E:38:C0:64
/ip dhcp-server lease add address=192.168.0.234 client-id=1:3c:e9:e:89:eb:a4 comment=Hoophouse-3 mac-address=3C:E9:0E:89:EB:A4 server=defconf
/ip dhcp-server lease add address=192.168.0.235 client-id=1:3c:e9:e:8a:13:44 mac-address=3C:E9:0E:8A:13:44 server=defconf
/ip dhcp-server lease add address=192.168.0.224 comment="Vue White" mac-address=84:0D:8E:38:C0:64 server=defconf
/ip dhcp-server lease add comment="Ecobee Well" mac-address=44:61:32:3D:A4:4A
/ip dhcp-server network add address=192.168.0.0/32 dns-server=192.168.0.11 gateway=192.168.0.1 netmask=24
/ip dns set allow-remote-requests=yes servers=1.1.1.1,8.8.8.8,9.9.9.9,8.8.4.4
/ip hotspot profile set [ find default=yes ] html-directory=hotspot
/ip ipsec profile set [ find default=yes ] dpd-interval=2m dpd-maximum-failures=5
/ip kid-control add fri=0s-1d mon=0s-1d name=Monitor sat=0s-1d sun=0s-1d thu=0s-1d tue=0s-1d wed=0s-1d
/ip route add disabled=no dst-address=0.0.0.0/0 gateway=192.168.0.1 routing-table=main suppress-hw-offload=no
/ip service set www-ssl disabled=no
/ip smb shares set [ find default=yes ] directory=/flash/pub
/system clock set time-zone-name=America/New_York
/system identity set name=355wap-carport
/system logging add topics=watchdog
/system logging add action=logserver prefix="serial=HDA08AX72ZK MikroTik" topics=hotspot
/system logging add action=logserver prefix="serial=HDA08AX72ZK MikroTik" topics=!debug,!packet,!snmp
/system logging add action=remote prefix="192.168.0.80 " topics=info
/system logging add disabled=yes topics=debug
/system note set show-at-login=no
/system ntp client set enabled=yes
/system ntp client servers add address=0.id.pool.ntp.org
/system ntp client servers add address=1.id.pool.ntp.org
/system scheduler add interval=2d name=export-download on-event=export-download policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=2023-08-28 start-time=01:32:53
/system scheduler add interval=2w name=dynamic-data-rextended on-event=dynamic-data-rextended policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=2023-09-30 start-time=02:58:29
/system scheduler add disabled=yes interval=5m name=Data_to_Splunk on-event=Data_to_Splunk_using_Syslog policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=2024-09-06 start-time=20:24:13
/system scheduler add name=SystemInfoJRS on-event=":delay 60\
\n/system script run SystemInfoJRS" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-time=startup
/system script add dont-require-permissions=no name=export-download owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/system\r\
\n:local cdate [clock get date] \r\
\n:local yyyy [:pick \$cdate 0 4]\r\
\n:local MM [:pick \$cdate 5 7]\r\
\n:local dd [:pick \$cdate 8 10]\r\
\n:local identitydate \"\$[identity get name]_\$yyyy-\$MM-\$dd\"\r\
\n/export show-sensitive file=\"\$identitydate\"\r\
\n\r\
\n/tool fetch upload=yes mode=ftp ascii=no src-path=\"/\$[\$identitydate].rsc\" dst-path=\"/mikrotik-backups/\$[\$identitydate].rsc\" address=192.168.2.22 port=21 user=mikrotik password=mikrotik\r\
\n\r\
\n/file remove \"\$[\$identitydate].rsc\"\r\
\n\r\
\n:log info (\"Uploaded rsc backup to 192.168.2.22 as \".\$identitydate)\r\
\n\r\
\n"
/system script add dont-require-permissions=no name=backup owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/system\r\
\n:local cdate [clock get date] \r\
\n:local yyyy [:pick \$cdate 0 4]\r\
\n:local MM [:pick \$cdate 5 7]\r\
\n:local dd [:pick \$cdate 8 10]\r\
\n:local identitydate \"\$[identity get name]_\$yyyy-\$MM-\$dd\"\r\
\n\r\
\n\r\
\n/system backup save name=\$identitydate\r\
\n\r\
\n/tool fetch upload=yes mode=ftp ascii=no src-path=\"/\$[\$identitydate].backup\" dst-path=\"/mikrotik-backups/\$[\$identitydate].backup\" address=192.168.2.22 port=21 user=mikrotik password=mikrotik\r\
\n\r\
\n/file remove \"\$[\$identitydate].backup\"\r\
\n\r\
\n"
/system script add dont-require-permissions=no name="Get IP Addresses" owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/interface bridge host\r\
\n:foreach item in=[find] do={\r\
\n :local iface [get \$item interface]\r\
\n :local macadd [get \$item mac-address]\r\
\n :local idmac [/ip arp find where mac-address=\$macadd]\r\
\n :if ([:len \$idmac] = 1) do={\r\
\n :local ifip [/ip arp get \$idmac address]\r\
\n :local HOST [/ip arp get \$idmac hostname]\r\
\n :put \"interface=\$iface mac=\$macadd ip=\$ifip\"\r\
\n :log info \"interface=\$iface mac=\$macadd ip=\$ifip\"\r\
\n\r\
\n }\r\
\n}\r\
\n"
/system script add dont-require-permissions=no name=hello owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=" :log info \"hello\""
/system script add dont-require-permissions=no name=dynamic-data-rextended owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/system\r\
\n:local identitydate \"\$[identity get name]_\$[clock get date]\"\r\
\n:local stringexec \"/system iden print; :put \\\"\\\\r\\\\n\\\"; /ip cloud pri; :put \\\"\\\\r\\\\n\\\"; /ip dhcp-server lease pri det; :put \\\"\\\\r\\\\n\\\"; /int bridge host pri det\"\r\
\n\r\
\n:if ([:len [/system package find where name=\"wifiwave2\"]] > 1) do={\r\
\n :set stringexec \"\$stringexec; :put \\\"\\\\r\\\\n\\\" /int wifiwave2 reg pri det\"\r\
\n} \r\
\n\r\
\n:if ([:len [/system package find where name=\"wifiwave2\"]] > 1) do={\r\
\n :set stringexec \"\$stringexec; :put \\\"\\\\r\\\\n\\\" /int wireless reg pri det\"\r\
\n}\r\
\n\r\
\n\r\
\n/file remove [find where name=tmpresults.txt]\r\
\n:delay 1s\r\
\n:execute \$stringexec file=tmpresults.txt\r\
\n:delay 2s\r\
\n\r\
\n/tool fetch upload=yes mode=ftp ascii=no address=192.168.2.22 port=21 user=mikrotik password=mikrotik \\\r\
\n src-path=tmpresults.txt dst-path=\"/mikrotik-backups/\$identitydate-dynamicdata.txt\"\r\
\n\r\
\n/file remove [find where name=tmpresults.txt]"
/system script add dont-require-permissions=no name=Data_to_Splunk_using_Syslog owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="# Collect information from Mikrotik RouterOS\r\
\n# Jotne 2024\r\
\n# Script name=Data_to_Splunk_using_Syslog\r\
\n:log info message=\"script=version ver=5.6\"\r\
\n# ----------------------------------\r\
\n\r\
\n# Auto update syslog server. 5.3-5.4.\r\
\n# Change <your syslog dns name> to the dns of your syslog server.\r\
\n# The update is disabled by default. Remove the # from the two next line to use it.\r\
\n\r\
\n#:local mySyslog [resolve <your syslog dns name>]\r\
\n#/system/logging/action/set [find where name=\"logserver\"] remote=\$mySyslog\r\
\n\r\
\n\r\
\n# What data to collect. Set to false to skip the section \r\
\n# ----------------------------------\r\
\n:local SystemResource true\r\
\n:local SystemInformation true\r\
\n:local SystemHealth true\r\
\n:local TrafficData true\r\
\n:local AccountData true\r\
\n:local uPnP true\r\
\n:local Wireless true\r\
\n:local AddressLists true\r\
\n:local DHCP true\r\
\n:local Neighbor true\r\
\n:local InterfaceData true\r\
\n:local CmdHistory true\r\
\n:local CAPsMANN false\r\
\n\r\
\n:local Routing true\r\
\n:local OSPF false\r\
\n:local BGP false\r\
\n\r\
\n:local PPP true\r\
\n:local IPSEC true\r\
\n\r\
\n# Get RouterOS main version (used to run different script on different version)\r\
\n:local train [:tonum [:pick [/system resource get version] 0 1]] \r\
\n\r\
\n# Collect system resource\r\
\n# ----------------------------------\r\
\n:if (\$SystemResource) do={\r\
\n\t/system resource\r\
\n\t:local cpuload [get cpu-load]\r\
\n\t:local freemem ([get free-memory]/1048576)\r\
\n\t:local totmem ([get total-memory]/1048576)\r\
\n\t:local freehddspace ([get free-hdd-space]/1048576)\r\
\n\t:local totalhddspace ([get total-hdd-space]/1048576)\r\
\n\t:local up [get uptime]\r\
\n\t:local sector [get write-sect-total]\r\
\n\t:log info message=\"script=resource free_memory=\$freemem MB total_memory=\$totmem MB free_hdd_space=\$freehddspace MB total_hdd_space=\$totalhddspace MB cpu_load=\$cpuload uptime=\$up write-sect-total=\$sector\"\r\
\n}\r\
\n\r\
\n\r\
\n# Make some part only run every hours\r\
\n# ----------------------------------\r\
\n:global Hour\r\
\n:local run false\r\
\n:local hour [:pick [/system clock get time] 0 2]\r\
\n:if (\$Hour != \$hour) do={\r\
\n\t:global Hour \$hour\r\
\n\t:set run true\r\
\n}\r\
\n\r\
\n\r\
\n# Get NTP status\r\
\n# ----------------------------------\r\
\n:local ntpstatus \"\"\r\
\n:if ([:len [/system package find where !disabled and name=ntp]] > 0 or [:tonum [:pick [/system resource get version] 0 1]] > 6) do={\r\
\n :set ntpstatus [/system ntp client get status]\r\
\n} else={\r\
\n :if ([:typeof [/system ntp client get last-update-from]] = \"nil\") do={\r\
\n :set ntpstatus \"using-local-clock\"\r\
\n } else={\r\
\n :set ntpstatus \"synchronized\"\r\
\n }\r\
\n}\r\
\n:log info message=\"script=ntp status=\$ntpstatus\" \r\
\n\r\
\n\r\
\n# Get interface traffic data for all interface\r\
\n# ----------------------------------\r\
\n:if (\$TrafficData) do={\r\
\n\t:foreach id in=[/interface find] do={\r\
\n\t\t:local output \"\$[/interface print stats as-value where .id=\$id]\"\r\
\n\t\t:set ( \"\$output\"->\"script\" ) \"if_traffic\"\r\
\n\t\t:log info message=\"\$output\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n# Get traffic data v2 (Kid Control)\r\
\n# ----------------------------------\r\
\n:if (\$AccountData) do={\r\
\n\t:foreach logline in=[/ip kid-control device find] do={\r\
\n\t\t:local output \"\$[/ip kid-control device get \$logline]\"\r\
\n\t\t:set ( \"\$output\"->\"script\" ) \"kids\"\r\
\n\t\t:log info message=\"\$output\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n# Finding dynmaic lines used in uPnP\r\
\n# ----------------------------------\r\
\n:if (\$uPnP) do={\r\
\n\t:foreach logline in=[/ip firewall nat find where dynamic=yes and comment~\"^upnp \"] do={\r\
\n\t\t:local output \"\$[/ip firewall nat print as-value from=\$logline]\"\r\
\n\t\t:set ( \"\$output\"->\"script\" ) \"upnp\"\r\
\n\t\t:log info message=\"\$output\" \r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n# Collect system information 5.5 added ID for non routerBoard 5.6 Remvoed serial\r\
\n# ----------------------------------\r\
\n:local model na\r\
\n:local ffirmware na\r\
\n:local cfirmware na\r\
\n:local ufirmware na\r\
\n:if (\$SystemInformation and \$run) do={\r\
\n\t:local version ([/system resource get version])\r\
\n\t:local board ([/system resource get board-name])\r\
\n\t:local identity ([/system identity get name])\r\
\n\t:do {\r\
\n\t\t:if (\$board!=\"CHR\" OR \$board!=\"x86\") do={\r\
\n\t\t\t/system routerboard\r\
\n\t\t\t:set model ([get model])\r\
\n\t\t\t:set ffirmware ([get factory-firmware])\r\
\n\t\t\t:set cfirmware ([get current-firmware])\r\
\n\t\t\t:set ufirmware ([get upgrade-firmware])\r\
\n\t\t}\r\
\n\t} on-error={}\r\
\n\t:log info message=\"script=sysinfo version=\\\"\$version\\\" board-name=\\\"\$board\\\" model=\\\"\$model\\\" identity=\\\"\$identity\\\" factory-firmware=\\\"\$ffirmware\\\" current-firmware=\\\"\$cfirmware\\\" upgrade-firmware=\\\"\$ufirmware\\\"\"\r\
\n}\r\
\n\r\
\n\r\
\n# Collect system health\r\
\n# ----------------------------------\r\
\n:if (\$train > 6 and \$SystemHealth) do={\r\
\n\t# New version (RouterOS >6)\r\
\n\t:foreach id in=[/system health find] do={\r\
\n\t\t:local health \"\$[/system health get \$id]\"\r\
\n\t\t:set ( \"\$health\"->\"script\" ) \"health\"\r\
\n\t\t:log info message=\"\$health\"\r\
\n\t}\r\
\n} else={\r\
\n\t# Old version (RouterOS 6 or older)\r\
\n\t:if (!([/system health get]~\"(state=disabled|^\\\$)\")) do={\r\
\n\t\t:local health \"\$[/system health get]\"\r\
\n\t\t:set ( \"\$health\"->\"script\" ) \"health\"\r\
\n\t\t:log info message=\"\$health\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n\r\
\n# Sends wireless client data to log server \r\
\n# ----------------------------------\r\
\n:if (\$Wireless && [:len [/int find where type=wlan]]>0) do={\r\
\n\t/interface wireless registration-table\r\
\n\t:foreach i in=[find] do={\r\
\n\t\t:log info message=\".id=\$i;ap=\$([get \$i ap]);interface=\$([get \$i interface]);mac-address=\$([get \$i mac-address]);signal-strength=\$([get \$i signal-strength]);tx-rate=\$([get \$i tx-rate]);uptime=\$([get \$i uptime]);script=wifi\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n# Count IP in address-lists\r\
\n#----------------------------------\r\
\n:if (\$AddressLists) do={\r\
\n\t:local array [ :toarray \"\" ]\r\
\n\t:local addrcntdyn [:toarray \"\"] \r\
\n\t:local addrcntstat [:toarray \"\"] \r\
\n\t:local test\r\
\n\t:foreach id in=[/ip firewall address-list find] do={\r\
\n\t\t:local rec [/ip firewall address-list get \$id]\r\
\n\t\t:local listname (\$rec->\"list\")\r\
\n\t\t:local listdynamic (\$rec->\"dynamic\")\r\
\n\t\t:if (!(\$array ~ \$listname)) do={ :set array (\$array , \$listname) }\r\
\n\t\t:if (\$listdynamic = true) do={\r\
\n\t\t\t:set (\$addrcntdyn->\$listname) (\$addrcntdyn->\$listname+1)\r\
\n\t\t} else={\r\
\n\t\t\t:set (\$addrcntstat->\$listname) (\$addrcntstat->\$listname+1)}\r\
\n\t}\r\
\n\t:foreach k in=\$array do={\r\
\n\t\t:log info message=(\"script=address_lists list=\$k dynamic=\".((\$addrcntdyn->\$k)+0).\" static=\".((\$addrcntstat->\$k)+0))}\r\
\n}\r\
\n\r\
\n\r\
\n# Get MNDP (CDP) Neighbors\r\
\n# ----------------------------------\r\
\n:if (\$Neighbor and \$run) do={\r\
\n\t:foreach neighborID in=[/ip neighbor find] do={\r\
\n\t\t:local nb [/ip neighbor get \$neighborID]\r\
\n\t\t:local id [:pick (\"\$nb\"->\".id\") 1 99]\r\
\n\t\t:foreach key,value in=\$nb do={\r\
\n\t\t\t:local newline [:find \$value \"\\n\"]\r\
\n\t\t\t:if ([\$newline]>0) do={\r\
\n\t\t\t\t:set value [:pick \$value 0 \$newline]\r\
\n\t\t\t}\r\
\n\t\t\t:log info message=\"script=neighbor nid=\$id \$key=\\\"\$value\\\"\"\r\
\n\t\t}\r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n# Collect DHCP Pool information\r\
\n# ----------------------------------\r\
\n:if (\$DHCP and \$run) do={\r\
\n\t/ip pool {\r\
\n\t\t:local poolname\r\
\n\t\t:local pooladdresses\r\
\n\t\t:local poolused\r\
\n\t\t:local minaddress\r\
\n\t\t:local maxaddress\r\
\n\t\t:local findindex\r\
\n\r\
\n# Iterate through IP Pools\r\
\n\t\t:foreach pool in=[find] do={\r\
\n\t\t\t:set poolname [get \$pool name]\r\
\n\t\t\t:set pooladdresses 0\r\
\n\t\t\t:set poolused 0\r\
\n\r\
\n# Iterate through current pool's IP ranges\r\
\n\t\t\t:foreach range in=[:toarray [get \$pool range]] do={\r\
\n\r\
\n# Get min and max addresses\r\
\n\t\t\t\t:set findindex [:find [:tostr \$range] \"-\"]\r\
\n\t\t\t\t:if ([:len \$findindex] > 0) do={\r\
\n\t\t\t\t\t:set minaddress [:pick [:tostr \$range] 0 \$findindex]\r\
\n\t\t\t\t\t:set maxaddress [:pick [:tostr \$range] (\$findindex + 1) [:len [:tostr \$range]]]\r\
\n\t\t\t\t} else={\r\
\n\t\t\t\t\t:set minaddress [:tostr \$range]\r\
\n\t\t\t\t\t:set maxaddress [:tostr \$range]\r\
\n\t\t\t\t}\r\
\n\r\
\n# Calculate number of ip in one range\r\
\n\t\t\t\t:set pooladdresses (\$maxaddress - \$minaddress)\r\
\n\r\
\n# /foreach range\r\
\n\t\t\t}\r\
\n\r\
\n# Test if pools is used in DHCP or VPN and show leases used\r\
\n\t\t\t:local dname [/ip dhcp-server find where address-pool=\$poolname]\r\
\n\t\t\t:if ([:len \$dname] = 0) do={\r\
\n# No DHCP server found, assume VPN\r\
\n\t\t\t\t:set poolused [:len [used find pool=[:tostr \$poolname]]]\r\
\n\t\t\t} else={\r\
\n# DHCP server found, count leases\r\
\n\t\t\t\t:local dname [/ip dhcp-server get [find where address-pool=\$poolname] name]\r\
\n\t\t\t\t:set poolused [:len [/ip dhcp-server lease find where server=\$dname]]}\r\
\n\r\
\n# Send data\r\
\n\t\t\t:log info message=(\"script=pool pool=\$poolname used=\$poolused total=\$pooladdresses\")\r\
\n\r\
\n# /foreach pool\r\
\n\t\t}\r\
\n# /ip pool\r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n# Get detailed command history RouterOS >= v7\r\
\n# ----------------------------------\r\
\n:if (\$train > 6 and \$CmdHistory) do={\r\
\n\t:global cmd\r\
\n\t:local f 0\r\
\n\t:foreach i in=[/system history find] do={\r\
\n\t\t:if (\$i = \$cmd) do={ :set f 1 }\r\
\n\t\t:if (\$f != 1) do={\r\
\n\t\t\t:log info message=\"StartCMD\"\r\
\n\t\t\t:log info message=[/system history get \$i]\r\
\n\t\t\t:log info message=\"EndCMD\"\r\
\n\t\t}\r\
\n\t}\r\
\n\t:global cmd [:pick [/system history find] 0]\r\
\n}\r\
\n\r\
\n\r\
\n# Test if CAPsMANN is installed and run script 5.5\r\
\n# ----------------------------------\r\
\n:if ( ([:len [/interface find where type=\"cap\"]] > 0) and \$CAPsMANN) do={ \r\
\n\t/system script run CAPsMANN\r\
\n}\r\
\n\r\
\n\r\
\n\r\
\n# Collect routing information\r\
\n# ----------------------------------\r\
\n:if (\$Routing) do={\r\
\n\t/ip route\r\
\n\t:foreach id in=[find] do={\r\
\n\t\t:local route \"\$[get \$id]\"\r\
\n\t\t:set ( \"\$route\"->\"script\" ) \"route\"\r\
\n\t\t:log info message=\"\$route\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n:if (\$OSPF) do={\r\
\n\t/routing ospf neighbor\r\
\n\t:foreach id in=[find] do={\r\
\n\t\t:local ospf \"\$[get \$id]\"\r\
\n\t\t:set ( \"\$ospf\"->\"script\" ) \"ospf\"\r\
\n\t\t:log info message=\"\$ospf\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n:if (\$BGP) do={\r\
\n\t/routing bgp session\r\
\n\t:foreach id in=[find] do={\r\
\n\t\t:local bgp \"\$[get \$id]\"\r\
\n\t\t:set ( \"\$bgp\"->\"script\" ) \"bgp\"\r\
\n\t\t:log info message=\"\$bgp\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n\r\
\n# Collect PPP/IPSEC\r\
\n# ----------------------------------\r\
\n:if (\$PPP) do={\r\
\n\t/ppp active\r\
\n\t:foreach id in=[find] do={\r\
\n\t\t:local ppp \"\$[get \$id]\"\r\
\n\t\t:set ( \"\$ppp\"->\"script\" ) \"ppp\"\r\
\n\t\t:log info message=\"\$ppp\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n:if (\$IPSEC) do={\r\
\n\t/ip ipsec active-peers\r\
\n\t:foreach id in=[find] do={\r\
\n\t\t:local ipsec \"\$[get \$id]\"\r\
\n\t\t:set ( \"\$ipsec\"->\"script\" ) \"ipsec\"\r\
\n\t\t:log info message=\"\$ipsec\"\r\
\n\t}\r\
\n}\r\
\n\r\
\n# End Script\r\
\n\r\
\n"
/system script add dont-require-permissions=yes name=Netwatch owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="####################################\r\
\n# Netwatch script\r\
\n#\r\
\n# Used as both up and down script\r\
\n# Created Jotne 2021 v1.5\r\
\n#\r\
\n####################################\r\
\n:local Host \$host\r\
\n/tool netwatch\r\
\n:local Status [get [find where host=\"\$Host\"] status]\r\
\n:local Comment [get [find where host=\"\$Host\"] comment]\r\
\n:local Interval [get [find where host=\"\$Host\"] interval]\r\
\n:local Since [get [find where host=\"\$Host\"] since]\r\
\n:log info \"script=netwatch watch_host=\$Host comment=\\\"\$Comment\\\" status=\$Status interval=\$Interval since=\\\"\$Since\\\"\""
/system script add dont-require-permissions=no name=SystemInfoJRS owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="\
\n# Collect system resource\
\n\t/system resource\
\n\t:local cpuload [get cpu-load]\
\n\t:local freemem ([get free-memory]/1048576)\
\n\t:local totmem ([get total-memory]/1048576)\
\n\t:local freehddspace ([get free-hdd-space]/1048576)\
\n\t:local totalhddspace ([get total-hdd-space]/1048576)\
\n\t:local up [get uptime]\
\n\t:local sector [get write-sect-total]\
\n\t:log info message=\"free_memory=\$freemem MB total_memory=\$totmem MB free_hdd_space=\$freehddspace MB total_hdd_space=\$totalhddspace MB cpu_load=\$cpuload uptime=\$up write-sect-total=\$sector\"\
\n\
\n\
\n\
\n# Collect system information 5.5 added ID for non routerBoard 5.6 Remvoed serial\
\n:local model na\
\n:local ffirmware na\
\n:local cfirmware na\
\n:local ufirmware na\
\n\
\n\t:local version ([/system resource get version])\
\n\t:local board ([/system resource get board-name])\
\n\t:local identity ([/system identity get name])\
\n\t:do {\
\n\t\t:if (\$board!=\"CHR\" OR \$board!=\"x86\") do={\
\n\t\t\t/system routerboard\
\n\t\t\t:set model ([get model])\
\n\t\t\t:set ffirmware ([get factory-firmware])\
\n\t\t\t:set cfirmware ([get current-firmware])\
\n\t\t\t:set ufirmware ([get upgrade-firmware])\
\n\t\t}\
\n\t} on-error={}\
\n\t:log info message=\"version=\\\"\$version\\\" board-name=\\\"\$board\\\" model=\\\"\$model\\\" identity=\\\"\$identity\\\"\"\
\n\
\n\
\n# Collect IP addresses\
\n:foreach neighborID in=[/ip address find] do={\
\n\t\t:local nb [/ip address get \$neighborID]\
\n\t\t:local id [:pick (\"\$nb\"->\".id\") 1 99]\
\n\t\t:foreach key,value in=\$nb do={\
\n\t\t\t:local newline [:find \$value \"\\n\"]\
\n\t\t\t:if ([\$newline]>0) do={\
\n\t\t\t\t:set value [:pick \$value 0 \$newline]\
\n\t\t\t}\
\n\t\t\t:if (\$key~\"add\") do={\
\n#\t\t\t:log info message=\"script=IP-ADDRESSES nid=\$id value=\$key=\\\"\$value\\\"\"\
\n\
\n\t\t\t:log info message=\"System IP Address \$value\"\
\n\t\t }\
\n\t }\
\n}\
\n\
\n\
\n# Collect system health\
\n#\t:foreach id in=[/system health find] do={\
\n#\t\t:local health \"\$[/system health get \$id]\"\
\n#\t\t:set ( \"\$health\"->\"script\" ) \"health\"\
\n#\t\t:log info message=\"\$health\"\
\n#\t}\
\n\
\n\
\n\
\n\
\n# Get MNDP (CDP) Neighbors\
\n#\t:foreach neighborID in=[/ip neighbor find] do={\
\n#\t\t:local nb [/ip neighbor get \$neighborID]\
\n#\t\t:local id [:pick (\"\$nb\"->\".id\") 1 99]\
\n#\t\t:foreach key,value in=\$nb do={\
\n#\t\t\t:local newline [:find \$value \"\\n\"]\
\n#\t\t\t:if ([\$newline]>0) do={\
\n#\t\t\t\t:set value [:pick \$value 0 \$newline]\
\n#\t\t\t}\
\n#\t\t\t:log info message=\"script=neighbor nid=\$id \$key=\\\"\$value\\\"\"\
\n#\t\t}\
\n#\t}\
\n\
\n\
\n\
\n\
\n\
\n"
/system watchdog set auto-send-supout=yes ping-start-after-boot=10m ping-timeout=7m send-email-from=joseph@domain.com send-email-to=joseph@domain.com watch-address=1.1.1.1
/tool netwatch add disabled=no down-script=Netwatch host=1.1.1.1 http-codes="" interval=5m name=Netwatch-1.1.1.1 test-script="" type=simple up-script=Netwatch
/tool romon set enabled=yes
/tool sniffer set filter-interface=all filter-mac-address=3C:E9:0E:89:EB:A4/FF:FF:FF:FF:FF:FF