Beispiel #1
0
def countries_vis(request):
	server_list = database_helper.get_server_list()
	end_date=datetime.now()
	start_date=datetime_helper.get_daterange_start(31)
	start_day=start_date.day
	start_month=start_date.month
	start_year=start_date.year
	end_day=end_date.day
	end_month=end_date.month
	end_year=end_date.year
	return render_to_response('countries_vis.html', {'server_list': server_list, 'start_day':start_day,'start_month':start_month,'start_year':start_year,'end_day':end_day,'end_month':end_month,'end_year':end_year});
def parse_rtt_measurements(hash):
	result = []
	data = []
	dstips = []
	device = database_helper.get_device_by_hash(hash).replace(':','')
	filename = settings.PROJECT_ROOT + '/summary/measurements/rtt/' + device
	#garbage characters to be removed:
	remove = ')("\n'
	ipr = database_helper.get_server_list()
	try:
		with open(filename,'r') as f:
			#each line represents one measurement record:
			for record in f:
				entry = []
				for i in range(0,len(remove)):
					record = record.replace(remove[i],'')
				record = record.split('|')
				#eventstamp:
				entry.append(int(record[0]))
				#average:
				entry.append(float(record[1]))
				#mserver address:
				dstip = record[2]
				entry.append(dstip)
				if dstip not in dstips and dstip!='':
					dstips.append(dstip)
				data.append(entry)
	#file not found:
	except:
		return result
	#sort by eventstamp:
	sorted_data = sorted(data, key=lambda x: x[0])
	#group data into sub-series by measurement server
	for dstip in dstips:
		mserver = ipr.filter(ip=dstip)
		if len(mserver)==0:
			continue
		#measurements are grouped by dstip, though dstip itself is discarded:
		series_data = [(x,y) for x,y,z in sorted_data if  z==dstip]
		series = dict(name=mserver[0].location,type='line',data=series_data)
		result.append(series)
	return result
Beispiel #3
0
def parse_rtt_measurements(hash):
    result = []
    data = []
    dstips = []
    device = database_helper.get_device_by_hash(hash).replace(':', '')
    filename = settings.PROJECT_ROOT + '/summary/measurements/rtt/' + device
    #garbage characters to be removed:
    remove = ')("\n'
    ipr = database_helper.get_server_list()
    try:
        with open(filename, 'r') as f:
            #each line represents one measurement record:
            for record in f:
                entry = []
                for i in range(0, len(remove)):
                    record = record.replace(remove[i], '')
                record = record.split('|')
                #eventstamp:
                entry.append(int(record[0]))
                #average:
                entry.append(float(record[1]))
                #mserver address:
                dstip = record[2]
                entry.append(dstip)
                if dstip not in dstips and dstip != '':
                    dstips.append(dstip)
                data.append(entry)
    #file not found:
    except:
        return result
    #sort by eventstamp:
    sorted_data = sorted(data, key=lambda x: x[0])
    #group data into sub-series by measurement server
    for dstip in dstips:
        mserver = ipr.filter(ip=dstip)
        if len(mserver) == 0:
            continue
        #measurements are grouped by dstip, though dstip itself is discarded:
        series_data = [(x, y) for x, y, z in sorted_data if z == dstip]
        series = dict(name=mserver[0].location, type='line', data=series_data)
        result.append(series)
    return result
Beispiel #4
0
def countries_vis(request):
    server_list = database_helper.get_server_list()
    end_date = datetime.now()
    start_date = datetime_helper.get_daterange_start(31)
    start_day = start_date.day
    start_month = start_date.month
    start_year = start_date.year
    end_day = end_date.day
    end_month = end_date.month
    end_year = end_date.year
    return render_to_response(
        'countries_vis.html', {
            'server_list': server_list,
            'start_day': start_day,
            'start_month': start_month,
            'start_year': start_year,
            'end_day': end_day,
            'end_month': end_month,
            'end_year': end_year
        })