blob: 9c11bd62bfd36ca3027ed4e57bbe161a8efd94bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/bin/bash
sleep=1
stats1=($(ethtool -S ens11 | grep -P "rx\d?_(packets|bytes)" | awk '{ print $2 }'))
sleep $sleep
stats2=($(ethtool -S ens11 | grep -P "rx\d?_(packets|bytes)" | awk '{ print $2 }'))
for i in "${!stats1[@]}"; do
diff=$(bc <<< "(${stats2[$i]} - ${stats1[$i]}) / $sleep")
if [ $((i & 1)) -eq 0 ]; then
if [ $i -lt 2 ]; then
echo -n "Total:"
elif [ $i -lt 4 ]; then
echo -n "Phi :"
else
echo -n "Queue:"
fi
printf "packets: %9.3f kpps" $(bc -l <<< "1 * $diff / 1000")
else
printf ", bandwidth: %9.3f Gb/s\n" $(bc -l <<< "8. * $diff / 1024 / 1024 / 1024")
fi
#echo $i
done
|