Hi guys,
This is my first post here, I’m a Network Engineer who works a lot with Mikrotik devices and Server Administration and you can see more of my posts on my website. I found this blog some time ago and was invited to contribute with some of my own scripts that may help others!
Today i’ll show you a little script for RouterOS to check if queue tree exceed the limit you set.
For. Example I’ve got a queue tree that limits the amount of 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={ :log info ("Queue not Exceeded") } :if ( $checkrate > $limit ) do={ :log info ("Queue Exceeded") /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) }Enjoy!Advertisement
hi mr razol,
could you give me how script for this case:
– ping host name then result auto send to email
Hi razorblade, how can this script be configured to be sent automatically upon the queue tree limit being exceeded? Following the article verbatim, the script can only be run manually. Thank you in advance!
Hi guys,
@Isaac this script can be scheduled by Mikrotik Scheduler (System -> Scheduler) so you can check whenever you want.
@ferdy i’ll get you the script asap!!
hi
i need you help with this script
:local dumplist [/queue simple find]
:foreach i in=$dumplist do={
:local targ
:set targ [/queue simple get $i target];
:if ($targ = “16.16.16.200”) do={
/queue simple set $i max-limit=400k/512k
}}
i want to check if the target address is equal to 16.16.16.200 then i limit its speed
this script run with no errors but gives no result in fact
thank you
Hi Ibrahim,
It’s because the IP addresses in the queue are recognised with a trailing subnet mask (IE: the actual address is 10.16.16.200/32)
Would this simplified version work?
/queue simple set [find target="10.16.16.200/32"] max-limit=400k/512k
– Andrew
thank you Omega-00
it works fine after i follow your instructions 😀
but i complete my work with that code
:local dumplist [/queue simple find]
:foreach i in=$dumplist do={
:local targ
:local traff
:set traff [/queue simple get $i byte];
:set targ [/queue simple get $i target];
:if ($targ = “16.16.16.91/32”) do={
:if ($traff>300) do={
/queue simple set $i max-limit=128k/128k
}}}
but it give me this messege (Script Error: cannot compare if string is more than time interval
)
what can i do???
thanks again