TAIL MIKROTIK LOGS

{
:local lastLogTime

:while (true) do={
:local newLogs [ /log find time>$lastLogTime ]

:foreach logEntry in=$newLogs do={
    :local logMessage [ /log get $logEntry message ]
    :put ("Log Entry: " . $logMessage)
    :if ([:find $logMessage "authorizing"] > 0)  do={

    # Find the positions of the parentheses
    :local startPos [:find $logMessage "("];
    :local endPos [:find $logMessage ")" startPos];

    # Extract the IP address
    :local ip [:pick $logMessage ($startPos + 1) $endPos];

    # Output the IP address
    :put $ip;

    :local authr [/ip hotspot host find address=$ip]

    :put $authr
    :if ($authr != "") do={
        /ip hotspot host remove $authr;
        :log info "Netpap  Removed Hotspot Stale host with IP $ip";
    }

}

}

:set lastLogTime ([ /log find (time>$lastLogTime) ]->latest->get "time")

:delay 1s

}

}

Powered by BetterDocs


en_USEnglish