Am 2013-07-22 14:42, schrieb Silvan Jegen:
> The code is really simple and adjusting it to a particular interface
> name is trivial. Still, instead of checking for the interface names
> you
> are interested in, it may be easier to consider all the interfaces
> except the loop device.
>
> I will try to find the time to check whether there is an easy approach
> that covers all the cases you mention.
Here is a snippet from my current dwm status shell script which sums up
all interfaces
except the loopback one.
rx_now=0
tx_now=0
for i in /sys/class/net/*; do
if [[ -d "$i" && ${i##*/} != "lo" ]]; then
if [[ -f "$i/statistics/rx_bytes" ]]; then
let rx_now=($rx_now+`cat
$i/statistics/rx_bytes`)
fi
if [[ -f "$i/statistics/tx_bytes" ]]; then
let tx_now=($tx_now+`cat
$i/statistics/tx_bytes`)
fi
fi
done
let rx_rate=($rx_now-$rx_old)
let tx_rate=($tx_now-$tx_old)
--Markus
Received on Mon Jul 22 2013 - 15:17:45 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 22 2013 - 15:24:06 CEST