def clear_single_link_maas_message(dbcc, msg): link_id = msg.link_id db_flow_data_list = [] #Save it in mean database and convert to db layout object for flow_data in msg.flow_data: db_flow_data = db_layout.FlowData.new( dbcc, link_id, flow_data.start_time, flow_data.stop_time, flow_data.source_ip, flow_data.destination_ip, flow_data.num_of_packets, flow_data.num_of_bytes) db_flow_data_list.append(db_flow_data) db_layout.FlowData.save_many(dbcc, db_flow_data_list) #Process flowdata flows_ts_data = map(db_layout.FlowData.to_tuple_without_link_id, db_flow_data_list) flows_ts_output_list = flows_ts.process_flow_data(flows_ts_data) #Save it in fetched database bp_fetched_objects = [] for unix_timestamp_time, throughput_bps in flows_ts_output_list: bp_fetched_objects.append( db_layout.BPFetched.new(dbcc, link_id, unix_timestamp_time, throughput_bps)) db_layout.BPFetched.save_many(dbcc, bp_fetched_objects) err.log_error(err.INFO, "Cleared " + str(len(msg.flow_data)) + " rows of flow data") return sr.SuppliedFlowData.from_bp_fetched_list_to_supplied_info( bp_fetched_objects)
def clear_single_link_maas_message(dbcc, msg): link_id = msg.link_id db_flow_data_list = [] # Save it in mean database and convert to db layout object for flow_data in msg.flow_data: db_flow_data = db_layout.FlowData.new( dbcc, link_id, flow_data.start_time, flow_data.stop_time, flow_data.source_ip, flow_data.destination_ip, flow_data.num_of_packets, flow_data.num_of_bytes, ) db_flow_data_list.append(db_flow_data) db_layout.FlowData.save_many(dbcc, db_flow_data_list) # Process flowdata flows_ts_data = map(db_layout.FlowData.to_tuple_without_link_id, db_flow_data_list) flows_ts_output_list = flows_ts.process_flow_data(flows_ts_data) # Save it in fetched database bp_fetched_objects = [] for unix_timestamp_time, throughput_bps in flows_ts_output_list: bp_fetched_objects.append(db_layout.BPFetched.new(dbcc, link_id, unix_timestamp_time, throughput_bps)) db_layout.BPFetched.save_many(dbcc, bp_fetched_objects) err.log_error(err.INFO, "Cleared " + str(len(msg.flow_data)) + " rows of flow data") return sr.SuppliedFlowData.from_bp_fetched_list_to_supplied_info(bp_fetched_objects)
(1415976534072, 1415976534452, "94.158.244.121", "197.54.83.168", 25, 4500), (1415976534072, 1415976542410, "63.186.70.228", "115.25.102.105", 8131, 683295), (1415976534072, 1415976542318, "242.187.113.6", "42.252.1.97", 48, 5616), (1415976534072, 1415976541525, "107.238.231.33", "203.147.45.231", 24, 6000), (1415976534072, 1415976541513, "42.207.135.95", "205.203.67.67", 3792, 319680), (1415976534072, 1415976541472, "253.155.255.33", "100.209.59.77", 24, 3168) ] print test_flow_data_list bytes_total = 0 for a, b, c, d, e, bytes in test_flow_data_list: bytes_total += bytes time_throughput_list = flows_ts.process_flow_data(test_flow_data_list) print time_throughput_list processed_bytes_total = 0 for f, bytes in time_throughput_list: processed_bytes_total += bytes print "Total: " + str(bytes_total) print "Processed total: " + str(processed_bytes_total) difference = abs(bytes_total - processed_bytes_total) print "Difference: " + str(difference) perc = difference / bytes_total * 100 print "Difference percentage from unprocessed total: " + str(perc)
, (1415976534072, 1415976544915, "246.25.18.234", "37.246.84.22", 8443, 715183) , (1415976534072, 1415976545289, "252.50.110.46", "100.101.144.11", 821, 76195) , (1415976534072, 1415976544230, "35.119.22.201", "37.82.243.223", 24, 2688) , (1415976534072, 1415976534452, "94.158.244.121", "197.54.83.168", 25, 4500) , (1415976534072, 1415976542410, "63.186.70.228", "115.25.102.105", 8131, 683295) , (1415976534072, 1415976542318, "242.187.113.6", "42.252.1.97", 48, 5616) , (1415976534072, 1415976541525, "107.238.231.33", "203.147.45.231", 24, 6000) , (1415976534072, 1415976541513, "42.207.135.95", "205.203.67.67", 3792, 319680) , (1415976534072, 1415976541472, "253.155.255.33", "100.209.59.77", 24, 3168) ] print test_flow_data_list bytes_total = 0 for a, b, c, d, e, bytes in test_flow_data_list: bytes_total += bytes time_throughput_list = flows_ts.process_flow_data(test_flow_data_list) print time_throughput_list processed_bytes_total = 0 for f, bytes in time_throughput_list: processed_bytes_total += bytes print "Total: " + str(bytes_total) print "Processed total: " + str(processed_bytes_total) difference = abs(bytes_total - processed_bytes_total) print "Difference: " + str(difference) perc = difference / bytes_total * 100 print "Difference percentage from unprocessed total: " + str(perc)