diff options
Diffstat (limited to 'analyze3.sh')
-rwxr-xr-x | analyze3.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/analyze3.sh b/analyze3.sh new file mode 100755 index 0000000..256a4c5 --- /dev/null +++ b/analyze3.sh @@ -0,0 +1,54 @@ +#! /bin/bash + +sleep=1 + +#Doesn't work with LibVMA. +#iptables -D INPUT -p udp --match multiport --dports 4000:4100 -j traf &> /dev/null +#iptables -X traf &> /dev/null +#iptables -N traf +#iptables -A INPUT -p udp --match multiport --dports 4000:4100 -j traf +#iptables -Z traf +#iptables -L traf -v -n -x + +function stat { + ints=$1 + + for i in "${!ints[@]}"; do + int="${ints[$i]}" + stats1[$i]=$(ethtool -S $int | grep -P "rx_(packets|bytes)_phy" | awk '{ print $2 }') + done + sleep $sleep + for i in "${!ints[@]}"; do + int="${ints[$i]}" + stats2[$i]=$(ethtool -S $int | grep -P "rx_(packets|bytes)_phy" | awk '{ print $2 }') + done + + pksum=0 + bwsum=0 + for i in "${!stats1[@]}"; do + stat1=(${stats1[$i]}) + stat2=(${stats2[$i]}) + + pk1=${stat1[0]} + pk2=${stat2[0]} + + bw1=${stat1[1]} + bw2=${stat2[1]} + + pkdiff=$(bc <<< "($pk2 - $pk1) / $sleep") + bwdiff=$(bc <<< "($bw2 - $bw1) / $sleep") + + printf "%10s" "${ints[$i]}" + printf " packets: %9.3f kpps" $(bc -l <<< "1. * $pkdiff / 1000") + printf ", bandwidth: %9.3f Gb/s\n" $(bc -l <<< "8. * $bwdiff / 1024 / 1024 / 1024") + + pksum=$(($pksum + $pkdiff)) + bwsum=$(($bwsum + $bwdiff)) + done + printf "%10s" "Total" + printf " packets: %9.3f kpps" $(bc -l <<< "1. * $pksum / 1000") + printf ", bandwidth: %9.3f Gb/s\n" $(bc -l <<< "8. * $bwsum / 1024 / 1024 / 1024") +} + +ints=(ens1 ens11 ens1d1 ens11d1) +stat $ints |