Friday, May 6, 2016

E-Mail alert on queue tree limit exceeded

I will show you a little script of Mikrotik RouterOS to check queue and mail if queue tree exceed the limit you set.
For example we have a queue tree that limits the amount of total traffic (Upload+Download) to 2Mbps.
I want to know whenever this queue exceed the limit, and the system will send me an email alart.
This is the script:
Assume that a que tree name=total-traffic
total-traffic
:global checkrate [/queue tree get total-traffic rate]
:local limit 2000000
 
:if ( $checkrate < $limit ) do={
:log info ("Queue not Exceeded")
}
:if ( $checkrate > $limit ) do={
:log info ("Queue Exceeded")
/tool e-mail send server=xxx.xxx.xxx.xxx from="me@myself.com" to="me@myself.com" subject=("Queue Limit Exceed name=total-traffic") body=("Queue Limit Exceed name=total-traffic, Limit is: " . $checkrate)
}


Enjoy!

1 comment: