Community discussions

MikroTik App
 
eldoncito2019
Member
Member
Topic Author
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Reset all counters

Fri Mar 25, 2022 8:52 pm

Friends, how will be a script to automatically reset all NAT counters?
Thank you for your answers.





EL DONCITO.
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Reset all counters

Fri Mar 25, 2022 9:07 pm

Friend, define automatically ?

Manually it is: /ip/firewall/nat reset-counters-all
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Reset all counters  [SOLVED]

Fri Mar 25, 2022 9:15 pm

/ip firewall nat reset-counters-all
Add it to a scheduler if you like to reset it a certain time.
Last edited by Jotne on Sat Mar 26, 2022 9:59 am, edited 1 time in total.
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Reset all counters

Fri Mar 25, 2022 11:00 pm

So the definition of automatically was time.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Reset all counters

Sat Mar 26, 2022 12:28 am

/ip filter nat reset-counters-all
The solution is IP filter??? :roll: :P

Reset all NAT counters at midnight:
/system scheduler
add interval=1d name=NAT_reset_counters policy=read,write start-date=mar/25/2022 start-time=23:59:59 \
    on-event="/ip firewall nat reset-counters-all" 

Reset NAT counters at midnight, ONLY when inside the comment is present RST (all uppercase) on any part of the comment:
/system scheduler
add interval=1d name=NAT_reset_counters_on_RST_comment policy=read,write start-date=mar/25/2022 start-time=23:59:59 \
     on-event="/ip firewall nat reset-counters [find where comment~\"RST\"]"

Reset NAT counters at midnight, EXCEPT when inside the comment is present KP (all uppercase) on any part of the comment:
/system scheduler
add interval=1d name=NAT_reset_counters_on_not_KP_comment policy=read,write start-date=mar/25/2022 start-time=23:59:59 \
     on-event="/ip firewall nat reset-counters [find where !(comment~\"KP\")]"
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Reset all counters

Tue Nov 15, 2022 10:43 pm

Hi @Rextended!

This option DOES work:
/ip firewall raw reset-counters [find where comment~"IPSec"]
This option does NOT work
/ip firewall raw reset-counters [find where src-address-list="BlacklistIPSEC"]
Why? only filter by comments?

Thx & BR.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Reset all counters

Wed Nov 16, 2022 11:54 am

This option does NOT work
/ip firewall raw reset-counters [find where src-address-list="BlacklistIPSEC"]

What you obtain with:
:put [/ip firewall raw find where src-address-list="BlacklistIPSEC"]
one (or more) index number like *3f1,*84a"?
For me on v6 work.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Reset all counters

Wed Nov 16, 2022 5:34 pm

What you obtain with:
:put [/ip firewall raw find where src-address-list="BlacklistIPSEC"]
one (or more) index number like *3f1,*84a"?
For me on v6 work.
I tested the following:
:put [/ip firewall raw find where src-address-list="BlacklistIPSEC"]
Result: *5
:put [/ip firewall raw reset-counters [/ip firewall raw find where src-address-list="BlacklistIPSEC"]]
Reset counters only from BlacklistIPSEC --> OK.

Thanks!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Reset all counters

Wed Nov 16, 2022 5:40 pm

Thanks!
:)

Who is online

Users browsing this forum: drpioneer, JDF and 22 guests