def setup_capture_job(shark): def create_job(): interface = shark.get_interfaces()[0] if shark.model == 'vShark': job = shark.create_job(interface, 'Flyscript-tests-job', '10%', indexing_size_limit='2GB', start_immediately=True) else: job = shark.create_job(interface, 'Flyscript-tests-job', '400MB', indexing_size_limit='300MB', start_immediately=True) time.sleep(5) job.stop() return job try: job = shark.get_capture_job_by_name('Flyscript-tests-job') except ValueError: #let's create a capture job job = create_job() if job.size_on_disk == 0: #job has no packets, probably #the packet storage has been formatted #and lost all the packages job.delete() job = create_job() logger.info('using capture job %r' % job) return job
def setup_capture_job(shark): try: job = shark.get_capture_job_by_name('Flyscript-tests-job') except ValueError: #let's create a capture job interface = shark.get_interfaces()[0] job = shark.create_job(interface, 'Flyscript-tests-job', '20%', indexing_size_limit='2GB', start_immediately=True) logger.info('using capture job %r' % job) return job
if options.start_time is not None: start_time = TimeParser().parse(options.start_time) elif talkers.count() == 0: start_time = round_time(datetime.now()) print 'no start time, starting from %s' % start_time.strftime(timefmt) else: last = talkers.find(sort=[('$natural', pymongo.DESCENDING)]) last_tm = last[0]['time'] + timedelta(microseconds=1000*last[0]['length']) start_time = round_time(last_tm) print 'last record came at %s, starting at %s' % (str(last_tm), start_time.strftime(timefmt)) shark = rvbd.shark.Shark(options.sharkhost, auth=UserAuth('admin', 'admin')) job = shark.get_capture_job_by_name(options.jobname) def find_in_legend(l, n): for i in range(len(l)): if l[i].field == n: return i raise KeyError() from rvbd.shark.types import Value, Key def get_top_talkers(start, end): fields = ( Key('tcp.client_ip'), Key('tcp.server_ip'), Value('generic.bytes') ) print 'querying talkers in %r-%r' % (start, end)