https://forum.mikrotik.com/viewtopic.ph ... 13#p883975
Код: Выделить всё
:global fill do={
:local STR $1
:local LEN $2
:local CHAR $3
:if ([:len $STR] >= $LEN) do={
:set STR "$[:pick $STR 0 ($LEN-1)]$CHAR"
} else={
:for i from=1 to=($LEN-[:len $STR]) step=1 do={
:set STR "$STR$CHAR"
}
}
:return $STR
}
:put "$[$fill "MAC" 19 " "]$[$fill "IP" 17 " "]$[$fill "Client" 12 " "]$[$fill "AP" 10 " "]$[$fill "Signal" 7 " "]$[$fill "SSID" 18 " "]$[$fill "TX Rate" 11 " "]$[$fill "RX Rate" 11 " "]$[$fill "Uptime" 14 " "]$[$fill "Bytes" 21 " "]$[$fill "Packets" 15 " "]Interface"
/caps-man registration-table
:foreach i in=[find] do={
:local locMAC [get $i mac-address]
:local locInt [get $i interface]
:local locSSID [get $i ssid]
:local locSignal [get $i rx-signal]
:local loctxRate [get $i tx-rate]
:if ([:find $loctxRate "-" -1] > 0) do={:set loctxRate [:pick $loctxRate 0 [:find $loctxRate "-" -1]]}
:local locrxRate [get $i rx-rate]
:if ([:find $locrxRate "-" -1] > 0) do={:set locrxRate [:pick $locrxRate 0 [:find $locrxRate "-" -1]]}
:local locUptime [get $i uptime]
:set locUptime [:pick $locUptime 0 [:find $locUptime "." -1]]
:local locBytes [get $i bytes]
:local locPack [get $i packets]
/caps-man interface
:local locMasterInt [get [find where name=$locInt] master-interface]
:local locRadioMAC "00:00:00:00:00:00"
:if ($locMasterInt = "none") do={:set locRadioMAC [get [find where name=$locInt] radio-mac]} else={:set locRadioMAC [get [find where name=$locMasterInt] radio-mac]}
:local locCAP ""
/caps-man radio
:do {:set locCAP [get [find where radio-mac=$locRadioMAC] remote-cap-identity]} on-error={:put "ERROR - $locMAC - $locRadioMAC"}
:local locIP "noDHCP"
:local locName "noDHCP"
/ip dhcp-server lease
:if ([find where mac-address=$locMAC]) do={
:do {:set locIP [get [find where mac-address=$locMAC] address ]} on-error={:set locIP "DCHP-Err"; :put "ERROR with $locMAC - Please check DHCP for duplicate entries"}
:do {:set locName [get [find where mac-address=$locMAC] host-name]} on-error={:set locName "DHCP-Err"}
}
:if ($locSignal <= -70) do={:terminal style varname} else={:terminal style none}
:put "$[$fill $locMAC 19 " "]$[$fill $locIP 17 " "]$[$fill $locName 12 " "]$[$fill $locCAP 10 " "]$[$fill $locSignal 7 " "]$[$fill $locSSID 18 " "]$[$fill $loctxRate 11 " "]$[$fill $locrxRate 11 " "]$[$fill $locUptime 14 " "]$[$fill $locBytes 21 " "]$[$fill $locPack 15 " "]$locInt"
}