RouterOS对接云认证Hotspot认证,上报状态同时执行云端指令的脚本

Created: Nov. 16, 2019, 6:37 a.m. Updated: Nov. 16, 2019, 6:37 a.m.

RouterOS对接云认证Hotspot认证,上报状态同时执行云端指令的脚本

# by zhangdi <QQ:222411> ver 20161120
:global realm
  :if ([:len [/radius find disabled=no service=hotspot]] = 1) do={ 
  :set realm [/radius get [/radius find disabled=no service=hotspot] realm ]
} else={
:set realm
  :put "realm not found!"
  :log info ("realm not found!")
}

if ([:len [/system script job find]] > 5) do={
  :put "too many work to do!"
  :log info ("too many work to do!")
} else={
  if ([:len [$realm]]>0) do={
    :local mac [/interface ethernet get 0 mac-address ]
    :local cpuload [/system resource get cpu-load]
    :local uptime [/system resource get uptime]
    :local connow [/ip firewall connection tracking get total-entries]
    :local dhcplease [:len [/ip dhcp-server lease find ]]
    :local badblocks [/system resource get bad-blocks]
    :local hotspotoff [/ip hotspot get [find] disabled]
    :local radisurequests [:pick [/radius monitor 0 once as-value ] 1]
    :local radisutimeout [:pick [/radius monitor 0 once as-value ] 5]
    :local tolog ("mac=".$mac \
          ."&cpuload=".$cpuload \
          ."&uptime=".$uptime \
          ."&connow=".$connow \
          ."&dhcplease=".$dhcplease \
          ."&badblocks=".$badblocks \
          ."&hotspotoff=".$hotspotoff \
          ."&".$radisurequests . "&" . $radisutimeout \
      )
    /tool fetch url=("http://www.wlan-china.com/update" . $realm . "/?" . $tolog) keep-result=yes dst-path=wlanchina.rsc;
    :import wlanchina.rsc;
    :put "done!";
    :log info ("wlanchina status done. ".[/system clock get time])
  }
}