Scheduled check for loaded interfaces (auto adding queue to some IP or interface)
If you have MikroTik as main router on your network (business and residential clients using the same downlink) and you wont to make QoS for business users.
Simple: If your downlink is about 2Mbps and you grants business client min 1Mbit. But on the same MikroTik you have connected residential users. This script can check out-interface (for $sent-bits-per-second/$received-bits-per-second) and if sent/received bits > 1Mbps script can add queue for some interface or IP address(es).
/ system script
add name="TL_down_ip_to_64k" source="/interface monitor-traffic [/interface find name "interface"] once do {
- if ($sent-bits-per-second > 1048576) do {
/queue simple add name=(username . "_" . [:pick [/system clock get date] 4 6] . "-" . [:pick [/system clock get date] 0 3] . "-" . [:pick [/system clock get date] 7 11] . "-" . [:pick [/system clock get time] 0 9]) limit-at=64000/64000 max-limit=64000/64000 target-addresses="ip address" priority=1 } }" add name=" TL_remove_down" source="/interface monitor-traffic [/interface find name "interface"] once do {
- if ($sent-bits-per-second < 1048576) do {
/queue simple remove [/queue simple find target-addresses="ip address"] } }"
/ system scheduler
add name="name-loaded" on-event=TL_down_ip_to_64k start-date=jan/01/2007 start-time=00:00:00 interval=31m comment="" disabled=no
add name="name-unloaded" on-event=TL_remove_down start-date=jan/01/2007 start-time=00:00:00 interval=30m comment="" disabled=no