Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Dec 2020 15:03:40 -0800
From:      John-Mark Gurney <jmg@funkthat.com>
To:        Victor Gamov <vit@otcnet.ru>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Best way to get per second interface statistic
Message-ID:  <20201228230340.GP31099@funkthat.com>
In-Reply-To: <a76ee5e8-19f3-afa6-3664-07021bbfd739@otcnet.ru>
References:  <a76ee5e8-19f3-afa6-3664-07021bbfd739@otcnet.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Victor Gamov wrote this message on Mon, Dec 28, 2020 at 18:08 +0300:
> I have trunk port with many VLANs attached to FreeBSD 12.2-STABLE box 
> via ix0 interface.
> 
> What is the best way to get per second traffic statistic for ix0 
> interface and every VLAN?

Depends upon how you want to consume it.  netstat -w 1 -I <interface>
will dump the information, and it supports libxo, so you can do:
netstat -w 1 -I ix0 --libxo json

Though that isn't in a one json object per line per second, so
streaming it through jq or another json processor will likely be
difficult to get real time info from it...

And yes, if you have a lot of VLANs, that will me a lot of processes
running..

I don't know of any tool that will do it directly, but looking at
if.c from netstat:
https://cgit.freebsd.org/src/tree/usr.bin/netstat/if.c#n515

It looks like it isn't too hard, as calling getifaddrs (in libc)
looks like it returns all the info you want in the ifa_data for
any entry that is of type AF_LINE...

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201228230340.GP31099>