On May 13, 2014, Mike Lovell wrote: > this data is also available in sysfs. in
> /sys/class/net/$IFACE/statistics there should be rx_bytes and > tx_bytes which contain only the number matching those values. > just read the contents of those files and no need to awk or > even fork a process. yet another reason to love sysfs. That is handy. I hadn't thought of sysfs files. I do love sysfs. Anyone happen to know if the contents of /sys are documented anywhere besides within the kernel itself? I know that /proc files are mostly only documented in the kernel last I heard. That could save me some heavy time in the future. Thanks! --- Dan On Tue, May 13, 2014 at 10:25 AM, Mike Lovell <[email protected]> wrote: > On 05/13/2014 09:50 AM, Lonnie Olson wrote: > >> On Tue, May 13, 2014 at 1:07 AM, Dan Egli <[email protected]> wrote: >> >>> I was goofing around and decided I'd write a quick script that calls >>> ifconfig so as to determine how much bandwidth is being used (up and down >>> stream) on average. I wound up with something that I think would work, >>> but >>> I'm wondering if I can't do it better. >>> >> Not a bad idea, but better than forking out to ifconfig, might be to >> read from files in /proc. >> Example: >> awk '/^IpExt: [0-9]/{print $8 " " $9}' /proc/net/netstat >> or >> awk '/^IFACE/{print $2 " " $10}' /proc/net/dev >> etc. >> >> > this data is also available in sysfs. in /sys/class/net/$IFACE/statistics > there should be rx_bytes and tx_bytes which only contain the number > matching those values. just read the contents of those files and no need to > awk or even fork a process. yet another reason to love sysfs. > > mike > > > /* > PLUG: http://plug.org, #utah on irc.freenode.net > Unsubscribe: http://plug.org/mailman/options/plug > Don't fear the penguin. > */ > /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
