Enable firewall rule if queue limit is reached

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

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"]
}

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 :slight_smile:

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!!

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.

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 :slight_smile: