blob: d7c13b740f73dddc1d9ed82678441a9f7dc15a48 (
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
28
29
30
31
32
33
34
35
|
#! /bin/bash
sleep=1
# This doesn't work properly... Something is wrong with counters...
path=/mnt/ands/bin/vma_stats_mlx
#-z seems ignored
#$path -p $(pidof onlineDetectorSimulatorServer) -c 1 -z &> /dev/null
stats1=($($path -p $(pidof onlineDetectorSimulatorServer) -c 1 | grep Rx | awk '{ print $3, $4 }'))
sleep $sleep
stats2=($($path -p $(pidof onlineDetectorSimulatorServer) -c 1 | grep Rx | awk '{ print $3, $4 }'))
pksum=0
bwsum=0
for i in "${!stats2[@]}"; do
if [ -n "$stats1" ]; then
diff=$(bc <<< "(${stats2[$i]} - ${stats1[$i]}) / $sleep")
else
diff=$(bc <<< "${stats2[$i]} / $sleep")
fi
if [ $((i & 1)) -eq 0 ]; then
echo -n "Queue: "
printf "packets: %9.3f kpps" $(bc -l <<< "1. * $diff / 1000")
pksum=$(($pksum + diff))
else
printf ", bandwidth: %9.3f Gb/s\n" $(bc -l <<< "8. * $diff / 1024 / 1024")
bwsum=$(($bwsum + diff))
fi
done
echo -n "Total: "
printf "packets: %9.3f kpps" $(bc -l <<< "1. * $pksum / 1000")
printf ", bandwidth: %9.3f Gb/s\n" $(bc -l <<< "8. * $bwsum / 1024 / 1024")
|