Mikrotik RouterOS wifi 状态关联列表脚本

技术资料 分享,软路由,脚本
0 373
admin
admin 自由达人 2024-08-01 23:11:40
用户等级:5级
# :local interfaces {"wifi24", "wifi50"}
:local interfaces [/interface wifi find where disabled=no]
:local ledOn [:len $interfaces]

:foreach iface in=$interfaces do={
  :local nameIface [/interface get $iface name]
  # Number of connected devices
  :local count [:len [/interface wifi registration-table find where interface=$nameIface]]
  # Don't like this one as it always print the count in console
  #:local count [/interface wifi registration-table print count-only where interface=$nameIface]

  # Disable interface
  :if ($count = 0) do={
    /interface wifi set $iface disabled=yes
    # /interface wifi disable $iface
    :local ssidIface [/interface wifi get [find name=$nameIface] configuration.ssid]
    :log info message="Wifi \"$ssidIface\" ($nameIface) turned off"  
    set $ledOn ($ledOn - 1)
  }
}

# Switch off led
:if ($ledOn = 0 and ([/system leds get [find where leds="user-led"] type] = "on")) do={
  /system leds set [find where leds="user-led"] type=off
}

楼主签名:唱跳rap和篮球
回帖
回复列表