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: 993
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}
Tout individu a droit à la vie, à la liberté et à la sûreté de sa personne.
 
User avatar
Eugene
Forum Veteran
Forum Veteran
Posts: 993
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]]
Tout individu a droit à la vie, à la liberté et à la sûreté de sa personne.
 
User avatar
lastguru
Trainer
Trainer
Posts: 435
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>
International MikroTik Certified Trainer and Consultant form Latvia.
I do RouterOS Training and Certification worldwide!

skype: lastguru
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24493
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
No answer to your question? How to write posts
 
User avatar
[ASM]
Member Candidate
Member Candidate
Posts: 285
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.

Who is online

Users browsing this forum: No registered users and 58 guests