Community discussions

MikroTik App
 
Vulcanero
just joined
Topic Author
Posts: 2
Joined: Wed Mar 14, 2018 6:34 pm

How to calculate quantity of routes ?

Tue Feb 01, 2022 5:45 pm

Hello there !
Please help & tell me how I can to calculate quantity of routes ?

I need script which counts the number of routes.
I try to do so:
if ([ip route find where dst-address =0.0.0.0/0]>1) do={beep}
but it doesn't work.

This string: ip route print where dst-address =0.0.0.0/0 works fine - I get list of routes corresponding to the condition,
but how I can to count it ?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: How to calculate quantity of routes ?

Tue Feb 01, 2022 7:53 pm

This is how to print number of routes:
:put [:len [/ip route find where dst-address="0.0.0.0/0"]]
to get it inn to a variable
:local Routes  [:len [/ip route find where dst-address="0.0.0.0/0"]]
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7041
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: How to calculate quantity of routes ?

Wed Feb 02, 2022 10:43 am

Or
:global count [/ip route print count-only where dst-address="0.0.0.0/0"]

Who is online

Users browsing this forum: bertus and 30 guests