Exemplo n.º 1
0
    def main(self):
        # Print the high level shark info
        print 'APPLIANCE INFO:'

        info = self.shark.get_serverinfo()
        print '\tAppliance Version: ' + info['version']
        print '\tAppliance Hostname: ' + info['hostname']
        print '\tUptime: ' + str(info['uptime'])
        print '\tWeb UI TCP Port: {0}'.format(info['webui_port'])

        stats = self.shark.get_stats()
        print '\tPacket Storage: {0} total, {1} free, status:{2}'.format(
            bytes2human(stats['storage']['packet_storage'].total),
            bytes2human(stats['storage']['packet_storage'].unused),
            stats['storage']['packet_storage'].status)
        print '\tIndex Storage: {0} total, {1} free, status:{2}'.format(
            bytes2human(stats['storage']['os_storage']['index_storage'].total),
            bytes2human(stats['storage']['os_storage']['index_storage'].unused),
            stats['storage']['os_storage'].status)
        print '\tOS File System: {0} total, {1} free, status:{2}'.format(
            bytes2human(stats['storage']['os_storage']['disk_storage'].total),
            bytes2human(stats['storage']['os_storage']['disk_storage'].unused),
            stats['storage']['os_storage'].status)
        print '\tmemory: {0} total, {1} free, status:{2}'.format(
            bytes2human(stats['memory'].total),
            bytes2human(stats['memory'].available),
            stats['memory'].status)

        # Print the list of interfaces
        print 'INTERFACES:'
        for i in self.shark.get_interfaces():
            print '\t{0} (OS name: {1})'.format(i, i.name)

        # Print the list of trace files
        print 'TRACE FILES:'
        for f in self.shark.get_files():
            print '\t{0} ({1} bytes, created: {2})'.format(f, f.size, f.created)

        # Print the list of capture jobs
        print 'JOBS:'
        jobs = self.shark.get_capture_jobs()
        for j in jobs:
            print '\t{0} (size: {1}, src interface: {2})'.format(j, j.size_limit, j.interface)

        # Print the list of trace clips
        print 'TRACE CLIPS:'
        for c in self.shark.get_clips():
            if c.description == "":
                print '\t{0} ({1} bytes)'.format(c, c.size)
            else:
                print '\t{0}, {1} ({2} bytes)'.format(c.description, c, c.size)

        # Print the list of open views
        print 'OPEN VIEWS:'
        for view in self.shark.get_open_views():
            print '\t{0}'.format(view.handle)
            for output in view.all_outputs():
                print '\t\t{0}'.format(output.id)
Exemplo n.º 2
0
    def main(self):
        # Make the user pick a name for the job
        name = self.options.jobname
        if name is None:
            name = raw_input('Job name? ')

        # Make the user pick the capture port
        try:
            ifc = self.shark.get_interface_by_name(self.options.capture_port)
        except KeyError:
            print 'Capture Ports:'
            interfaces = self.shark.get_interfaces()
            for i, ifc in enumerate(interfaces):
                print '\t{0}. {1}'.format(i+1, ifc)

            while 1:
                idx = raw_input('Port number(1-{0})? '.format(len(interfaces)))
                try:
                    ifc = interfaces[int(idx)-1]
                    break
                except IndexError:
                    print 'Bad index try again'

        # Make the user pick the job size
        size = self.options.size
        if size is None:
            stats = self.shark.get_stats()
            storage = stats['storage']['packet_storage']
            print 'Storage size is {0}, {1} available'.format(bytes2human(storage.total),
                                                              bytes2human(storage.unused))
            size = raw_input('Job size, greater than 256MB (e.g. 1.1GB, 512M, 20%)? ')

        job = self.shark.create_job(ifc, name, size)
        print 'Capture Job successfully created with the following properties:'
        print ''
        print 'ID: %s' % job.id
        print 'Current State: %s' % job.get_state()
        print 'Name: %s' % job.name
        print 'Interface: %s' % job.interface
        print 'Source Path: %s' % job.source_path
        print 'Size limit: %s' % job.size_limit
        print 'Current size on disk: %s' % job.size_on_disk
        print ''