diff options
-rwxr-xr-x | vma-analyze.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vma-analyze.sh b/vma-analyze.sh new file mode 100755 index 0000000..d7c13b7 --- /dev/null +++ b/vma-analyze.sh @@ -0,0 +1,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") |