def analysis(self, direct_logs): dic_dla = {} for usefull_line in direct_logs: loginfo = log4cpp_files.LogInfo() loginfo.parser_worker_log(usefull_line.line) log_temp = loginfo.detail task_id = "" #send_log if usefull_line.category == self.send_direct_req: arr_info = DirectLiveTask.parser_send_detail_log(log_temp) task_id = arr_info[0] task_type = arr_info[1] if not dic_dla.get(task_id): dic_dla[task_id] = DirectLiveTask(task_id) dic_dla[task_id].task_type = task_type dic_dla[task_id].send_from_worker = loginfo elif self.is_recv_msg(usefull_line.category): task_id = DirectLiveTask.parser_recv_detail_log(log_temp) if not dic_dla.get(task_id): dic_dla[task_id] = DirectLiveTask(task_id) dic_dla[task_id].recv_on_worker.append(loginfo) return dic_dla
def save_to_db(self, db_filepath, usefull_lines): conn = sqlite3.connect(db_filepath) c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS direct_live_task (TASK_ID CHAR(50) NOT NULL, PID INT NOT NULL, THREAD_ID INT NOT NULL, TIMESTAMP_NUM INT NOT NULL, TIMESTAMP_STRING CHAR(50), CATEGORY CHAR(150), TYPE CHAR(150), LOG TEXT);''') for usefull_line in usefull_lines: loginfo = log4cpp_files.LogInfo() loginfo.parser_worker_log(usefull_line.line) log_temp = loginfo.detail task_id = "" task_type = usefull_line.category #send_log if usefull_line.category == self.send_direct_req: arr_info = DirectLiveTask.parser_send_detail_log(log_temp) task_id = arr_info[0] task_type = arr_info[1] elif self.is_recv_msg(usefull_line.category): task_id = DirectLiveTask.parser_recv_detail_log(log_temp) log = usefull_line.line log = log.replace("\"", "\"\"") sql_string = "INSERT INTO direct_live_task(TASK_ID, \ PID, \ THREAD_ID, \ TIMESTAMP_NUM, \ TIMESTAMP_STRING, \ CATEGORY, \ TYPE, \ LOG) VALUES(\"%s\", %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\")"%( task_id, int(loginfo.pid), int(loginfo.thread_id), log4cpp_files.string_to_ms(loginfo.time_string), loginfo.time_string, usefull_line.category, task_type, log ) #print(sql_string) c.execute(sql_string) conn.commit() conn.close() return
def save_to_db(self, db_filepath, usefull_lines): conn = sqlite3.connect(db_filepath) c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS fs_direct_live_task (TASK_ID CHAR(50) NOT NULL, PID INT NOT NULL, THREAD_ID INT NOT NULL, TIMESTAMP_NUM INT NOT NULL, TIMESTAMP_STRING CHAR(50), CATEGORY CHAR(50), MSG_TYPE CHAR(150), LOG TEXT);''') for usefull_line in usefull_lines: loginfo = log4cpp_files.LogInfo() loginfo.parser_fs_log(usefull_line.line) arr_task_info = self.parser_log(usefull_line.category, loginfo.detail) task_id = arr_task_info[0] task_type = arr_task_info[1] log = usefull_line.line log = log.replace("\"", "\"\"") #print(usefull_line.line) sql_string = "INSERT INTO fs_direct_live_task( \ TASK_ID, \ PID, \ THREAD_ID, \ TIMESTAMP_NUM, \ TIMESTAMP_STRING, \ CATEGORY, \ MSG_TYPE, \ LOG) VALUES(\"%s\", %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\")"%( task_id, int(loginfo.pid), int(loginfo.thread_id), log4cpp_files.string_to_ms(loginfo.time_string), loginfo.time_string, usefull_line.category, task_type, log ) #print(sql_string) c.execute(sql_string) conn.commit() conn.close() return
def save_to_db(db_filepath, usefull_lines): conn = sqlite3.connect(db_filepath) c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS discover_worker (PID INT NOT NULL, TIMESTAMP_NUM INT NOT NULL, TIMESTAMP_STRING CHAR(50), CATEGORY CHAR(150), TASK_ID CHAR(50), PARENT_TASK CHAR(50), ROOT_TASK CHAR(150), LOG TEXT);''') for usefull_line in usefull_lines: flow = RMAgentTaskFlow() flow.parser(usefull_line.line) log_info = log4cpp_files.LogInfo() log_info.parser_worker_log(usefull_line.line) log = usefull_line.line log = log.replace("\"", "\"\"") sql_string = "INSERT INTO discover_worker(PID, \ TIMESTAMP_NUM, \ TIMESTAMP_STRING, \ CATEGORY, \ TASK_ID, \ PARENT_TASK, \ ROOT_TASK, \ LOG) VALUES(%d, %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\")"%( flow.pid, log4cpp_files.string_to_ms(log_info.time_string), log_info.time_string, usefull_line.category, flow.task_id, flow.parent, flow.root, log ) c.execute(sql_string) conn.commit() conn.close() return