Today i’ll show you a little script for RouterOS to check if queue tree exceed the limit you set.
For. Example i’ve a queue tree that limit the amount o total traffic(Upload+Download) to 50MBps
I want to know whenever this queue exceed the limit, and i want the system to send me an email.
This is the script:
- :global checkrate [/queue tree get total-traffic rate]
- :local limit 50000000
- :if ( $checkrate < $limit ) do={
- }
- :if ( $checkrate > $limit ) do={
- /tool e-mail send server=xxx.xxx.xxx.xxx from="[email protected]" to="[email protected]" subject=("Queue Limit Exceed") body=("Queue Limit Exceed, Limit is: " . $checkrate)
- }
I’ll explain the code:
First i define a variable checkrate that represent the instant rate of the queue tree named total-traffic then i define a limit(this case i’ve used 50Mbps) then i check if rate less than limit do nothing or just log to test the script.
If checkrate greater than limit send an email to myself.
Be sure to specify as email server an IP address and not the name of the server(ex. mail.myself.com)
Enjoy!