All pastes #687288 Raw Edit

andarius

public text v1 · immutable
#687288 ·published 2007-09-08 17:05 UTC
rendered paste body
#!/bin/sh
# I used a sample file named "out" to test this.
# I did not verify the math. you may want to check
# it the first pass to be sure.
#
# This is likely more complex than it needs to be,
# however I am no scripting pro. Just like a trying
# things.
#
# If it chokes out saying something about the # being
# too big then you have one that starts with 0. I do
# not see that happening in the rx/tx columns. But
# just in case you have been notified.
#
# This one works with the output of "vnstat --dumpdb -i"

rx="0"
tx="0"

# Pull the hours:
#for i in $(cat output2 | cut -d ";" -f 2);
#do
#	echo $i
#done

# Pull the RX:
for i in $(cat output2 | cut -d ";" -f 3);
do
	rx=$(($[$rx] + $[$i]))
done

# Pull the TX:
for i in $(cat output2 | cut -d ";" -f 4);
do
	tx=$(($[$tx] + $[$i]))
done

echo "RX in kB = $rx"
echo "TX in kB = $tx"