Community discussions

MikroTik App
 
cheinzle
newbie
Topic Author
Posts: 36
Joined: Thu Oct 28, 2004 7:06 pm
Location: Nebraska

counting routes

Fri Nov 12, 2004 6:16 pm

Is there any way to count the number of routes in the routing table?
 
cheinzle
newbie
Topic Author
Posts: 36
Joined: Thu Oct 28, 2004 7:06 pm
Location: Nebraska

Fri Nov 12, 2004 6:34 pm

If I use the following to find all routes with a distance setting of 110:

> :set i [/ip route find distance=110]

then print the results:

> :put $i
*170,*182,*17A,*179,*177,*178,*16F,*17E,*176,*172,*175,*174,*173,*171,*17D

I get a list of route numbers. Can I then count these?
 
User avatar
Eugene
Forum Veteran
Forum Veteran
Posts: 986
Joined: Mon May 31, 2004 5:06 pm
Location: Cranfield, UK

Mon Nov 15, 2004 9:20 am

{:local a; :set a 0; :foreach i in [/ip route find distance=110] do={:incr a}; :put $a; :unset a}
 
User avatar
Eugene
Forum Veteran
Forum Veteran
Posts: 986
Joined: Mon May 31, 2004 5:06 pm
Location: Cranfield, UK

Mon Nov 15, 2004 9:31 am

In v2.9 new command len is available which greatly simplifies the task above, exempli gratia:
:put [:len [/ip route find interface=ether1]]
 
User avatar
lastguru
Member
Member
Posts: 432
Joined: Fri May 28, 2004 9:04 pm
Location: Certified Trainer/Consultant in Riga, Latvia
Contact:

Wed Nov 24, 2004 6:20 pm

Why not to use the count-only parameter for the print command?

[admin@mikrotik] ip route> print count-only
18
[admin@mikrotik] ip route>
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26322
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Thu Nov 25, 2004 9:33 am

very nice latsguru :) the simple solution is sometimes the best
 
User avatar
[ASM]
Member Candidate
Member Candidate
Posts: 284
Joined: Sun Jun 06, 2004 12:59 am
Location: Sofia, Bulgaria
Contact:

Thu Nov 25, 2004 8:26 pm

Why not to use the count-only parameter for the print command?

[admin@mikrotik] ip route> print count-only
18
[admin@mikrotik] ip route>
or :
/ip route print count-only from=[/ip route find distance=110]
 
cheinzle
newbie
Topic Author
Posts: 36
Joined: Thu Oct 28, 2004 7:06 pm
Location: Nebraska

Fri Dec 03, 2004 6:00 pm

thanks. very nice.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re:

Wed Sep 01, 2021 8:50 pm

/ip route print count-only from=[/ip route find distance=110]

Or simply...
/ip route print count-only where distance=110

Who is online

Users browsing this forum: alexantao and 16 guests