Best way to get per second interface statistic
John-Mark Gurney
jmg at funkthat.com
Mon Dec 28 23:03:47 UTC 2020
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."
More information about the freebsd-net
mailing list