From 14edb9061cd7c85ed1217de5514a5b5a2c0a1766 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Sat, 14 Aug 2010 10:55:40 +0300 Subject: [PATCH] ControlScripts: upload parsing support in parse_up_down_hrk.sh; upload and download matrix files are output in down/ and up/ folders --- ControlScripts/parse_up_down_log.sh | 71 ++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/ControlScripts/parse_up_down_log.sh b/ControlScripts/parse_up_down_log.sh index e2617df..356c234 100755 --- a/ControlScripts/parse_up_down_log.sh +++ b/ControlScripts/parse_up_down_log.sh @@ -33,22 +33,22 @@ fi log_folder=$1 -all_down=$(tempfile) -cat ${log_folder}/*.down > ${all_down} +all=$(tempfile) +cat ${log_folder}/*.updown > ${all} index=0 while read line; do date_array[$index]="$line" index=$(($index+1)) -done < <(cat ${all_down} | awk -F '[][]+' '{print $2;}' | sort -u) +done < <(cat ${all} | 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 +done > $log_folder/updown_date_index.cfg -peer_array=( $(cat ${all_down} | awk -F '[],() []+' ' +peer_array=( $(cat ${all} | awk -F '[],() []+' ' { - for (i = 5; i < NF; i += 3) { + for (i = 5; i < NF; i += 4) { print $i; j = i+1; print $j; @@ -58,17 +58,34 @@ peer_array=( $(cat ${all_down} | awk -F '[],() []+' ' for index in $(seq 1 ${#peer_array[@]}); do echo -e "$index\t${peer_array[$(($index-1))]}" -done > peer_index.cfg +done > $log_folder/updown_peer_index.cfg +# create download/upload basic folders and list files +mkdir $log_folder/down/ +mkdir $log_folder/up/ +> $log_folder/down_mat_files.lst +> $log_folder/up_mat_files.lst + +# populate download matrix files for index in $(seq 1 ${#date_array[@]}); do date=${date_array[$(($index-1))]} - out_file=$log_folder/$(echo "${date}.mat" | sed 's/ /-/g') + out_file=$(echo "${date}.mat" | sed 's/ /-/g') + echo "$out_file" >> $log_folder/down_mat_files.lst + echo "$out_file" >> $log_folder/up_mat_files.lst DEBUG echo "out_file: $out_file" - grep "${date}" ${all_down} | awk -F '[],()\t []+' ' + + > $log_folder/down/$out_file + > $log_folder/up/$out_file + + grep "${date}" ${all} | \ + awk -v config_file=$log_folder/updown_peer_index.cfg \ + -v down_output_file=$log_folder/down/$out_file \ + -v up_output_file=$log_folder/up/$out_file \ + -F '[],()\t []+' ' BEGIN { num_peers = 0; while (1) { - if ((getline < "peer_index.cfg") == 0) + if ((getline < config_file) == 0) break; num_peers++; peer_index_array[$1] = $2; @@ -77,33 +94,45 @@ BEGIN { close("peer_index.cfg"); for (i = 0; i < num_peers; i++) - for (j = 0; j < num_peers; j++) - matrix[i,j] = 0; + for (j = 0; j < num_peers; j++) { + down_matrix[i,j] = 0; + up_matrix[i,j] = 0; + } } { - for (i = 5; i < NF; i += 3) { + for (i = 5; i < NF; i += 4) { j = i+1; - k = i+2 + k = i+2; + l = i+3; + ip1 = $i; ip2 = $j; - speed = $k; + down_speed = $k; + up_speed = $l; + index1 = peer_ip_array[ip1]; index2 = peer_ip_array[ip2] - matrix[index1,index2] = speed; + down_matrix[index1,index2] = down_speed; + up_matrix[index1,index2] = up_speed; } } END { for (i = 0; i < num_peers; i++) { for (j = 0; j < num_peers; j++) { - if (matrix[i,j] == 0) - printf "0 "; + if (down_matrix[i,j] == 0) + printf "0 " >> down_output_file; + else + printf "%.2f ", down_matrix[i,j] >> down_output_file; + if (up_matrix[i,j] == 0) + printf "0 " >> up_output_file; else - printf "%.2f ", matrix[i,j]; + printf "%.2f ", up_matrix[i,j] >> up_output_file; } - printf "\n"; + printf "\n" >> down_output_file; + printf "\n" >> up_output_file; } -}' > $out_file +}' done -- 2.20.1