Am 2013-07-27 18:27, schrieb Martti Kühne:
On Mon, Jul 22, 2013 at 3:17 PM, Markus Teich
<markus.te...@stusta.mhn.de> wrote:

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
                        rx_now=($rx_now+`cat $i/statistics/rx_bytes`)
                fi
                if [[ -f "$i/statistics/tx_bytes" ]]; then
                        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)

Might I ask what shell dialect is that written in? O_o

Bash patched together with some stackoverflow answers.
It probably is not beautiful, but it works for me until I finally have
the time to write it in C. :/

--Markus

Reply via email to