From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anton Danilov Date: Wed, 10 Feb 2021 08:11:40 +0000 Subject: Re: Route count Message-Id: List-Id: References: <99dad522-5d1b-0d22-e215-9ee25e079ba3@spamtrap.tnetconsulting.net> In-Reply-To: <99dad522-5d1b-0d22-e215-9ee25e079ba3@spamtrap.tnetconsulting.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lartc@vger.kernel.org Hello. Instead of fetching all content of a route table, you can parse the /proc/net/fib_triestat file. It contents the number of prefixes for every routing table. On Mon, 8 Feb 2021 at 20:13, Grant Taylor wrote: > > Hi, > > Does anyone know a more efficient way to get a count of the number of > routes than to do something like the following? > > # ip route show table $TABLE | wc -l > > I'm doing something where I'd like to instrument the number of > (unreachable / null) routes once a minute and I'd like to avoid > unnecessary load on the system. > > It seems to me like there should be a counter somewhere that I can just > read instead of needing to enumerate every single route in the table. > > > > -- > Grant. . . . > unix || die > -- Anton Danilov.