On May 13, 2014, Brian J. Rogers wrote: > So what is the purpose of the script other than to show you
> your bandwidth > usage? I like the script, just wondering what you're doing > with it. Well, as I said, it mainly started as an intellectual exercise. But then I got to thinking that a couple of friends of mine, especially the guy who wanted to run an internet radio station, could use it to keep tabs on how much bandwidth they're using, so they know if their pipe is getting close to full and they need to make some kind of change. It's been a fun little challenge, converting to awk being the biggest challenge. I could do it with grep and cut, and I'm sure it would work fine. But since I wanted to learn awk anyway, I figured this would be a dual prong project. Get the script done, and start learning about awk syntax and abilities. --- Dan On Wed, May 14, 2014 at 11:10 PM, Dan Egli <[email protected]> wrote: > 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. */
