Commit 49dba4c8 authored by Deathcrow's avatar Deathcrow

data aggregation script (calculates average + std deviation)

parent fd070ae1
#!/usr/bin/env python3
# vim: expandtab shiftwidth=4 softtabstop=4
#iperf -V -Z cubic -t 30 -c fdb2:f689:4248:2bc8::3 -p 12345
import argparse
import copy
import math
import os
import re
import signal
import subprocess
import tempfile
#import threading
import time
def signal_handler(signum, frame):
clean_up()
raise SystemExit
def testy(a,b):
print(a)
print(b)
print(sender)
return 0
def clean_up():
# Clean up
if args.legacy:
tcpprobe.terminate()
if args.tcpdump == "1":
tcpdump.terminate()
if args.cpunetlog != "":
cpunetlog.terminate()
for i in sender:
# if i['utility'].returncode == None:
try:
i['utility'].kill()
except ProcessLookupError:
pass
# i['utility_file'].close()
time.sleep(1)
#def parse_dir(directory):
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
parser = argparse.ArgumentParser(description='Configure test environment.')
parser.add_argument('folders', nargs="*", default="./", help="Folder to search for files")
parser.add_argument('-m', '--mask')
args = parser.parse_args()
mypid = os.getpid()
#print(args.folders)
#for key, folder in enumerate(args.folders):
# args.folders[key] = os.path.abspath(folder)
args.folders = [os.path.abspath(folder) for folder in args.folders]
print(args.folders)
rtt_values_file = tempfile.TemporaryFile(mode='r+')
bw_values_file = tempfile.TemporaryFile(mode='r+')
rtt_file_lines = 0
bw_file_lines = 0
for folder in args.folders:
for path, dirs, files in os.walk(folder):
for file in files:
if file[:9] == "tcpprobe_":
tcpprobe_file = open(path + "/" + file)
for line in tcpprobe_file:
line = line.split(" ")
#print(line[9])
rtt_values_file.write(line[9]+'\n')
rtt_file_lines += 1
tcpprobe_file.close()
elif file[:3] == "bw_":
bw_file = open(path + "/" + file)
for line in bw_file:
line = line.split(" ")
bw_values_file.write(line[3])
bw_file_lines += 1
bw_file.close()
bw_values_file.seek(0)
rtt_values_file.seek(0)
avg_bw = sum( [ float(line) for line in bw_values_file ] ) / bw_file_lines
avg_rtt = sum( [ float(line) for line in rtt_values_file ] ) / rtt_file_lines
print("avg_bw: "+str(avg_bw))
print("avg_rtt: "+str(avg_rtt))
bw_values_file.seek(0)
rtt_values_file.seek(0)
std_deviation_bw = math.sqrt(1/(bw_file_lines - 1) * sum( [ (float(line)-avg_bw)**2 for line in bw_values_file ] ))
std_deviation_rtt = math.sqrt(1/(rtt_file_lines - 1) * sum( [ (float(line)-avg_rtt)**2 for line in rtt_values_file ] ))
print("std_deviation_bw: "+str(std_deviation_bw))
print("std_deviation_rtt: "+str(std_deviation_rtt))
#print(bw_values_file.read())
#print(bw_file_lines)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment