Created
January 23, 2025 08:08
-
-
Save kyob/09d6c637d9831cf33728578cb1f58ece to your computer and use it in GitHub Desktop.
Revisions
-
kyob created this gist
Jan 23, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ # MikroTik RouterOS Script: Monitor Queue Average Rate # Author: Łukasz Kopiszka # Description: Monitors queue usage in /queue tree and logs warning if average rate exceeds a specified threshold. # Units converted to Mb/s for readability. # Usage: Add the script to RouterOS, and optionally schedule it for periodic execution. # Example: # /system scheduler add name=monitor-queue-avg-rate interval=1m on-event=monitor-queue-avg-rate :local threshold 60 :foreach qId in=[/queue tree find] do={ :local qName [/queue tree get $qId name] :local qMaxLimit [/queue tree get $qId max-limit] :local qAvgRate [/queue tree get $qId rate] :if ($qMaxLimit > 0) do={ :local usagePercent (($qAvgRate * 100) / $qMaxLimit) :local avgRateMbps ($qAvgRate / 1000000) :local maxLimitMbps ($qMaxLimit / 1000000) :if ($usagePercent >= $threshold) do={ :log warning ("Queue '" . $qName . "' usage " . $usagePercent . "%, avgRate: " . $avgRateMbps . " Mb/s, limit: " . $maxLimitMbps . " Mb/s") } } }