2016-01-07 17:13:24 +03:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This script converts Network performance output files into csv files.
|
2016-04-02 11:52:10 +03:00
|
|
|
# Author: Srikanth Myakam
|
2016-01-07 17:13:24 +03:00
|
|
|
# Email : v-srm@microsoft.com
|
|
|
|
#
|
|
|
|
format_bites(){
|
2016-02-24 20:49:25 +03:00
|
|
|
temp_size=$1
|
|
|
|
temp_units="Gbps"
|
|
|
|
temp_size=`echo $temp_size 1000| awk '{printf "%.3f \n", $1/$2}'`
|
|
|
|
temp_size=`echo $temp_size 1000| awk '{printf "%.3f \n", $1/$2}'`
|
|
|
|
echo $temp_size,$temp_units
|
2016-01-07 17:13:24 +03:00
|
|
|
}
|
2016-02-24 20:49:25 +03:00
|
|
|
|
2016-01-07 17:13:24 +03:00
|
|
|
gen_csv(){
|
2016-02-24 20:49:25 +03:00
|
|
|
input_file=$1
|
|
|
|
number_of_connections=$2
|
2016-10-05 10:45:43 +03:00
|
|
|
summary_file=$3
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-02-24 20:49:25 +03:00
|
|
|
output_file=`echo $input_file |sed s/\.log$/\.csv/`
|
|
|
|
top_array_file=`echo $output_file |sed s/sar/top/`
|
|
|
|
conn_array_file=`echo $output_file |sed s/sar/connections/`
|
|
|
|
cpu_vmstat_file=`echo $input_file |sed s/sar/vmstat/`
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-10-05 10:45:43 +03:00
|
|
|
rx_pcks_array_file=$input_file-rxpcks.log
|
|
|
|
tx_pcks_array_file=$input_file-txpcks.log
|
2016-02-24 20:49:25 +03:00
|
|
|
rx_array_file=$input_file-rxkBps.log
|
|
|
|
tx_array_file=$input_file-txkBps.log
|
|
|
|
cpu_vmstat_array_file=$input_file-cpu-vmstat.log
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-10-07 07:24:41 +03:00
|
|
|
cat $cpu_vmstat_file | grep -v [a-z]| awk '{print 100 - $15}' > $cpu_vmstat_array_file
|
2016-10-05 10:45:43 +03:00
|
|
|
cat $input_file | grep eth0 | awk '{print $4}' > $rx_pcks_array_file
|
|
|
|
cat $input_file | grep eth0 | awk '{print $5}' > $tx_pcks_array_file
|
2016-02-24 20:49:25 +03:00
|
|
|
cat $input_file | grep eth0 | awk '{print $6}' > $rx_array_file
|
|
|
|
cat $input_file | grep eth0 | awk '{print $7}' > $tx_array_file
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-10-05 10:45:43 +03:00
|
|
|
rx_pcks_array=(`cat $rx_pcks_array_file`)
|
|
|
|
tx_pcks_array=(`cat $tx_pcks_array_file`)
|
2016-02-24 20:49:25 +03:00
|
|
|
rx_array=(`cat $rx_array_file`)
|
|
|
|
tx_array=(`cat $tx_array_file`)
|
|
|
|
top_array=(`cat $top_array_file`)
|
|
|
|
conn_array=(`cat $conn_array_file`)
|
|
|
|
cpu_array=(`cat $cpu_vmstat_array_file`)
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-02-24 20:49:25 +03:00
|
|
|
length=$((${#rx_array[@]}-1))
|
|
|
|
count=0
|
|
|
|
sum=0
|
2016-10-05 10:45:43 +03:00
|
|
|
rx_pcks_sum=0
|
|
|
|
tx_pcks_sum=0
|
2016-02-24 20:49:25 +03:00
|
|
|
rx_sum=0
|
|
|
|
tx_sum=0
|
2016-10-05 10:45:43 +03:00
|
|
|
cpu_sum=0
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-10-05 10:45:43 +03:00
|
|
|
echo Rx Throughput,Units,TxThroughput,Units,Total,Units,,Time,ActiveConnection,Rx packets,Tx packets,,Time,CPU Usage >> $output_file
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-02-24 20:49:25 +03:00
|
|
|
for i in `seq 1 $length`;
|
|
|
|
do
|
|
|
|
Tx_bits=`echo 8 ${tx_array[count]}| awk '{printf "%.3f \n", $1*$2}'`
|
|
|
|
Rx_bits=`echo 8 ${rx_array[count]}| awk '{printf "%.3f \n", $1*$2}'`
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-02-24 20:49:25 +03:00
|
|
|
Tx_data=`format_bites $Tx_bits`
|
|
|
|
Rx_data=`format_bites $Rx_bits`
|
|
|
|
Total_bits=`echo $Tx_bits $Rx_bits| awk '{printf "%.3f \n", $1+$2}'`
|
2016-01-07 17:13:24 +03:00
|
|
|
|
2016-02-24 20:49:25 +03:00
|
|
|
Total_data=`format_bites $Total_bits`
|
|
|
|
conn_info=${conn_array[count]}
|
|
|
|
if [ "x$conn_info" == "x" ]
|
|
|
|
then
|
|
|
|
conn_info=","
|
|
|
|
fi
|
|
|
|
|
2016-10-05 10:45:43 +03:00
|
|
|
echo $Rx_data,$Tx_data,$Total_data,,$conn_info,${rx_pcks_array[count]},${tx_pcks_array[count]},,$count,${cpu_array[count]}>> $output_file
|
|
|
|
rx_pcks_sum=`echo $rx_pcks_sum ${rx_pcks_array[count]}| awk '{printf "%.3f \n", $1+$2}'`
|
|
|
|
tx_pcks_sum=`echo $tx_pcks_sum ${tx_pcks_array[count]}| awk '{printf "%.3f \n", $1+$2}'`
|
2016-02-24 20:49:25 +03:00
|
|
|
rx_sum=`echo $rx_sum ${rx_array[count]}| awk '{printf "%.3f \n", $1+$2}'`
|
|
|
|
tx_sum=`echo $tx_sum ${tx_array[count]}| awk '{printf "%.3f \n", $1+$2}'`
|
2016-10-05 10:45:43 +03:00
|
|
|
cpu_sum=`echo $cpu_sum ${cpu_array[count]}| awk '{printf "%.3f \n", $1+$2}'`
|
2016-10-07 07:24:41 +03:00
|
|
|
|
2016-02-24 20:49:25 +03:00
|
|
|
((count++))
|
|
|
|
done
|
|
|
|
sum=`echo $tx_sum $rx_sum| awk '{printf "%.3f \n", $1+$2}'`
|
2016-10-05 10:45:43 +03:00
|
|
|
pcks_sum=`python -c "print '%d' % ($tx_pcks_sum+$rx_pcks_sum)"`
|
|
|
|
avg_thrpt=`python -c "print '%.2f' % ($sum*8/($length*1000*1000))"`
|
|
|
|
avg_cpu=`python -c "print '%d' % ($cpu_sum/$length)"`
|
|
|
|
|
|
|
|
echo $number_of_connections,$avg_thrpt,$pcks_sum,$avg_cpu >> $summary_file
|
2016-02-24 20:49:25 +03:00
|
|
|
rm -rf $rx_array_file $tx_array_file $cpu_vmstat_array_file.log
|
2016-01-07 17:13:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
logs_folder=$1
|
2016-12-08 13:49:50 +03:00
|
|
|
testtype=$2
|
|
|
|
buffersize=$3
|
2016-10-07 09:06:14 +03:00
|
|
|
#summary_file=$logs_folder/summary_file_`hostname`.csv
|
2016-12-08 13:49:50 +03:00
|
|
|
summary_file=$logs_folder/summary_file_`hostname`_${testtype}_${buffersize}.csv
|
2016-10-05 10:45:43 +03:00
|
|
|
echo "" > $summary_file
|
|
|
|
echo "Connections,Avg Throughput,Total packets,Avg CPU" > $summary_file
|
2016-10-07 07:24:41 +03:00
|
|
|
for number_of_connections in 1 2 4 8 16 32 64 128 256 512 1024
|
2016-01-07 17:13:24 +03:00
|
|
|
do
|
2016-04-01 18:10:18 +03:00
|
|
|
echo "Converting $number_of_connections logs.."
|
2016-10-05 10:45:43 +03:00
|
|
|
gen_csv $logs_folder/$number_of_connections/$number_of_connections-sar.log $number_of_connections $summary_file&
|
2016-01-07 17:13:24 +03:00
|
|
|
done
|
|
|
|
wait
|
2016-04-01 18:10:18 +03:00
|
|
|
|
|
|
|
mkdir -p $logs_folder/csv_files/
|
2016-10-07 07:24:41 +03:00
|
|
|
for number_of_connections in 1 2 4 8 16 32 64 128 256 512 1024
|
2016-04-01 18:10:18 +03:00
|
|
|
do
|
|
|
|
mv $logs_folder/$number_of_connections/$number_of_connections-sar.csv $logs_folder/csv_files/
|
|
|
|
done
|
|
|
|
|
2016-10-05 10:45:43 +03:00
|
|
|
cat $summary_file | sort -n > $summary_file.tmp
|
|
|
|
mv $summary_file.tmp $summary_file
|
2016-01-07 17:13:24 +03:00
|
|
|
logs_folder=`echo $logs_folder| sed 's/\/$//'`
|
2016-04-01 18:10:18 +03:00
|
|
|
tar -czf $logs_folder.tar.gz $logs_folder/
|
2016-04-01 20:07:01 +03:00
|
|
|
echo "Completed!"
|