From 658a480ea6beb6317333870c60af1b8875ff5b71 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Fri, 13 Aug 2010 20:20:34 +0300 Subject: [PATCH] ControlScripts: add script for parsing up peer-connection upload/download speed log files --- ControlScripts/parse_up_down_log.sh | 102 ++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 ControlScripts/parse_up_down_log.sh diff --git a/ControlScripts/parse_up_down_log.sh b/ControlScripts/parse_up_down_log.sh new file mode 100755 index 0000000..b10bdf0 --- /dev/null +++ b/ControlScripts/parse_up_down_log.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# +# 2010 Razvan Deaconescu, razvan.deaconescu@cs.pub.ro +# +# The script +# * parses multiple peer-connection upload/download speed log files +# +# Command line argument specifies log folder + +# use _DEBUG="off" to turn off debug printing +_DEBUG="off" + +if test $# -ne 1; then + echo "usage: $0 log-folder" 1>&2 + exit 1 +fi + +# Read the global configuration file +# Check if the global configuration file exists +if [ ! -e globalconfig ]; then + echo "Warning: The global config file globalconfig does not exist." +else + source globalconfig +fi + +# Read client mappings configuration file +# Check if the client mappings configuration file exists +if [ ! -e client_script_mappings ]; then + echo "Warning: The client mappings config file client_script_mappings does not exist." +else + source client_script_mappings +fi + +log_folder=$1 + +all_down=$(tempfile) +cat ${log_folder}/*.down > ${all_down} + +index=0 +while read line; do + date_array[$index]=$line + index=$(($index+1)) +done < <(cat ${all_down} | awk -F '[][]+' '{print $2;}' | sort -u) + +for index in $(seq 1 ${#date_array[@]}); do + echo -e "$index\t${date_array[$(($index-1))]}" +done > date_index.cfg + +peer_array=( $(cat ${all_down} | awk -F '[],() []+' ' +{ + for (i = 5; i < NF; i += 3) { + print $i; + j = i+1; + print $j; + } +} +' | sort -u) ) + +for index in $(seq 1 ${#peer_array[@]}); do + echo -e "$index\t${peer_array[$(($index-1))]}" +done > peer_index.cfg + +for date in ${date_array[@]}; do + grep "${date}" ${all_down} | awk -F '[],()\t []+' ' +BEGIN { + num_peers = 0; + while (1) { + if ((getline < "peer_index.cfg") == 0) + break; + num_peers++; + peer_index_array[$1] = $2; + peer_ip_array[$2] = $1; + } + close("peer_index.cfg"); + + for (i = 0; i < num_peers; num_peers++) + for (j = 0; i < num_peers; num_peers++) + matrix[i,j] = 0; +} + +{ + for (i = 5; i < NF; i += 3) { + j = i+1; + k = i+2 + ip1 = $i; + ip2 = $j; + speed = $k; + index1 = peer_ip_array[ip1]; + index2 = peer_ip_array[ip2] + matrix[index1,index2] = speed; + } +} + +END { + for (i = 0; i < num_peers; num_peers++) { + for (j = 0; i < num_peers; num_peers++) + printf "%.2f ", matrix[i,j]; + printf "\n"; + } +}' + +done -- 2.20.1