Exemplo n.º 1
0
def linegraph_bytes_port_hour(request):
    device = request.GET.get('deviceid')
    filter_by = request.GET.get('filter_by')

    port_names = ['Web','HTTPS','IMAPS','SMTPS','POP3S','JABBER','DNS','SMTP','SSH']
    port_high = [80,443,993,587,995,5223,53,25,22] 
    port_low = [80,443,993,587,995,5223,53,25,22] 

    details = Devicedetails.objects.filter(deviceid=device)[0]
	
    node = database_helper.deviceid_to_nodeid(device)

    all_device_details= BytesPerPortPerHour_mem.objects.all().order_by('eventstamp')

    device_details = all_device_details.filter(node_id=node)

    other_device_details = []
    filtered_deviceids = []	

    if (filter_by == 'location'):
	filtered_deviceids = Devicedetails.objects.filter(city=details.city).exclude(deviceid=device)

    if (filter_by == 'provider'):
	filtered_deviceids = Devicedetails.objects.filter(isp=details.isp).exclude(deviceid=device)

    for row in filtered_deviceids:
	other_device_details.extend(all_device_details.filter(deviceid=row.deviceid))
    
    result=[]
    for i in range(0,len(port_names)):
    	result.append(cvs_helper.linegraph_normal_passive(device_details.filter(port=port_high[i]),port_names[i]))

    '''
    if (filter_by != 'none'):
	bucket_width = 2*3600
	result.append(cvs_helper.linegraph_bucket(other_device_details,bucket_width,'median'))
    '''
    answer = str(result).replace("['","[")
    answer = answer.replace(")'",")")

    return HttpResponse("(" + answer + ")")
Exemplo n.º 2
0
def linegraph_bytes_hour(request):
    device = request.GET.get('deviceid')
    filter_by = request.GET.get('filter_by')

    details = Devicedetails.objects.filter(deviceid=device)[0]
	
    node = database_helper.deviceid_to_nodeid(device)

    all_device_details= BytesPerHour_mem.objects.all().order_by('eventstamp')

    device_details = all_device_details.filter(node_id=node)

    other_device_details = []
    filtered_deviceids = []	

    if (filter_by == 'location'):
	filtered_deviceids = Devicedetails.objects.filter(city=details.city).exclude(deviceid=device)

    if (filter_by == 'provider'):
	filtered_deviceids = Devicedetails.objects.filter(isp=details.isp).exclude(deviceid=device)

    for row in filtered_deviceids:
	other_device_details.extend(all_device_details.filter(deviceid=row.deviceid))
    
    result=[]
    result.append(cvs_helper.linegraph_normal_passive(device_details,'bytes per hour'))

    '''
    if (filter_by != 'none'):
	bucket_width = 2*3600
	result.append(cvs_helper.linegraph_bucket(other_device_details,bucket_width,'median'))
    '''
    answer = str(result).replace("['","[")
    answer = answer.replace(")'",")")

    return HttpResponse("(" + answer + ")")