Created
January 23, 2025 08:08
-
-
Save kyob/09d6c637d9831cf33728578cb1f58ece to your computer and use it in GitHub Desktop.
MikroTik RouterOS script to monitor queue usage and log warnings when average rate exceeds a specified threshold.
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 characters
| # 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") | |
| } | |
| } | |
| } |
Author
kyob
commented
Jan 25, 2025

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment