Community discussions

MikroTik App
 
uk52rob
just joined
Topic Author
Posts: 15
Joined: Mon May 16, 2005 9:37 am

Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 12:20 pm

Hi all,

I am having problems creating a script that I will run every 30 mins to do the following:

- If the Total Bytes in the simple queue "P2P Limit" > 500 Mb, then enable firewall rule "Block P2P", else end.

I then need a seperate script to run once a day to reset the counters on the simple queue "P2P Limit" and disable the firewall rule "Block P2P".

Any suggestions would be most grateful and welcome!

Thanks
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6332
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 12:29 pm

The script itself is quite simple
:if ( [/queue simple get [find name="P2P Limit"] total-bytes] > 500000000 ) do={
  /ip firewall filter enable [find comment="Block P2P"]
}
 
uk52rob
just joined
Topic Author
Posts: 15
Joined: Mon May 16, 2005 9:37 am

Re: Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 12:48 pm

Thanks - that works well!

How do I use the reset-counters-all on the simple queue "P2P Limit" in a script and disable the firewall rule "Block P2P"?

Cheers :)
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6332
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 1:28 pm

to reset counters
/queue simple reset-counters [find name="P2P Limit"]
disabling is the same as enabling
/ip firewall filter disable [find comment="Block P2P"]
 
uk52rob
just joined
Topic Author
Posts: 15
Joined: Mon May 16, 2005 9:37 am

Re: Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 1:38 pm

to reset counters
/queue simple reset-counters [find name="P2P Limit"]
disabling is the same as enabling
/ip firewall filter disable [find comment="Block P2P"]
Ahh, I had done reset-counters-all which did not work.

Thanks!!
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6284
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 2:36 pm

if you need to reset all counters you should use reset-counters-all, if you want to reset only those queues that have reached the limit, do as mrz suggested.
 
uk52rob
just joined
Topic Author
Posts: 15
Joined: Mon May 16, 2005 9:37 am

Re: Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 5:03 pm

I have just noticed that the 'Total Bytes' under the 'Total Statistics' tab in Winbox shows the same as the Target Upload 'Bytes' under the 'Statistics' tab. This does not account for the Target Download bytes.

How can I use the script to monitor the sum of the Target Upload and Target Download bytes?

Thanks!
 
uk52rob
just joined
Topic Author
Posts: 15
Joined: Mon May 16, 2005 9:37 am

Re: Enable firewall rule if queue limit is reached

Tue Apr 13, 2010 5:20 pm

I have just noticed that the 'Total Bytes' under the 'Total Statistics' tab in Winbox shows the same as the Target Upload 'Bytes' under the 'Statistics' tab. This does not account for the Target Download bytes.

How can I use the script to monitor the sum of the Target Upload and Target Download bytes?

Thanks!
Just to clarify - The 'Statistics' tab for the simple queue shows:

Target Upload Bytes - 17.0 MiB
Target Download Bytes - 129.0 MiB

Whereas the 'Total Statistics' tab shows:
Total Bytes - 17.0 MiB

Why does this not include the target download bytes?

If the Total Bytes cannot, for some reason, include the Target Download Bytes, then can I use the script to limit the Target Download and Target Upload bytes together, instead of the Total Bytes?

Thanks :)

Who is online

Users browsing this forum: No registered users and 31 guests