def iter_requests(self, pipe): timestamp = None host = 'unknown' for line in pipe: mo = re.match('\* Connected to ([^\s]+)', line) if mo: host = mo.group(1) log.info('New Connection: %s' % host) elif re.match('> GET ', line): #!TODO: handle other stderr output from wrapped tool req = urllib.unquote(line.strip()[2:]) request = DapRequest.from_get(host, req) log.info('Request: %s %s' % (timestamp, request)) assert timestamp is not None yield (timestamp, request) timestamp = None else: mo = re.match('(?:\[pid\s*(\d+)\])?\s*(\d+\.\d+)\s+(send|recv)', line) if mo: pid, timestamp, syscall = mo.groups() timestamp = float(timestamp) #!TODO: track pids # Mark terminal event log.info('End: %s' % timestamp) yield (timestamp, None)
def iter_requests(self, pipe): timestamp = None host = 'unknown' for line in pipe: mo = re.match('\* Connected to ([^\s]+)', line) if mo: host = mo.group(1) log.info('New Connection: %s' % host) elif re.match('> GET ', line): #!TODO: handle other stderr output from wrapped tool req = urllib.unquote(line.strip()[2:]) request = DapRequest.from_get(host, req) log.info('Request: %s %s' % (timestamp, request)) assert timestamp is not None yield (timestamp, request) timestamp = None else: mo = re.match( '(?:\[pid\s*(\d+)\])?\s*(\d+\.\d+)\s+(send|recv)', line) if mo: pid, timestamp, syscall = mo.groups() timestamp = float(timestamp) #!TODO: track pids # Mark terminal event log.info('End: %s' % timestamp) yield (timestamp, None)
def echofilter_to_stats(file_handle): """ Read the output from the custom grinder TCPProxy filter TimestampedEchoFilter to produce a DapStats object. """ #!FIXME: this doesn't work because the connection is only closed once. stats = DapStats() open_requests = {} request = {} for line in file_handle: mo = re.match('--- ((.*)->(.*)) (opened|closed) (\d+) --', line) # Can ignore open events if mo: connection_details, source, dest, event, timestamp = mo.groups() timestamp = float(timestamp) if event == 'closed': start_timestamp = open_requests[connection_details] host, port = dest.split(':') stats.add_request(host, start_timestamp / 1000, timestamp / 1000, request[connection_details]) del request[connection_details] mo = re.match('------ ((.*)->(.*)) (\d+) ------', line) if mo: connection_details, source, dest, timestamp = mo.groups() timestamp = float(timestamp) if connection_details in open_requests: start_timestamp = open_requests[connection_details] host, port = dest.split(':') stats.add_request(host, start_timestamp / 1000, timestamp / 1000, request[connection_details]) del request[connection_details] open_requests[connection_details] = timestamp continue mo = re.match('GET ', line) if mo: request[connection_details] = DapRequest.from_get(source, line) continue return stats
def echofilter_to_stats(file_handle): """ Read the output from the custom grinder TCPProxy filter TimestampedEchoFilter to produce a DapStats object. """ #!FIXME: this doesn't work because the connection is only closed once. stats = DapStats() open_requests = {} request = {} for line in file_handle: mo = re.match('--- ((.*)->(.*)) (opened|closed) (\d+) --', line) # Can ignore open events if mo: connection_details, source, dest, event, timestamp = mo.groups() timestamp = float(timestamp) if event == 'closed': start_timestamp = open_requests[connection_details] host, port = dest.split(':') stats.add_request(host, start_timestamp/1000, timestamp/1000, request[connection_details]) del request[connection_details] mo = re.match('------ ((.*)->(.*)) (\d+) ------', line) if mo: connection_details, source, dest, timestamp = mo.groups() timestamp = float(timestamp) if connection_details in open_requests: start_timestamp = open_requests[connection_details] host, port = dest.split(':') stats.add_request(host, start_timestamp/1000, timestamp/1000, request[connection_details]) del request[connection_details] open_requests[connection_details] = timestamp continue mo = re.match('GET ', line) if mo: request[connection_details] = DapRequest.from_get(source, line) continue return stats