Beispiel #1
0
def run_analysis(options):

    # Get our FTP IP
    try:
        ftp_ip = NET.get_ip_address(options.ftp_interface)
    except:
        logger.error("Could not find ip for the given interface. (%s)"%
                     options.ftp_interface)
            
    # Add a sensors to physical machines if needed
    if options.machine_type == G.MACHINE_TYPES.PHYSICAL:
        has_memory = has_disk = False
        
        if options.machine_config is None:
            logger.error("No machine config file given.")
            return
        
        # This isn't the class we use in practice, but fake it here for simplicity
        machines = CONF.import_from_config(options.machine_config, "machine")
    
        if options.machine not in machines:
            logger.error("%s is not a valid machine from the config file."%options.machine)
            logger.error("Valid targets are: %s"%machines.keys())
            return

        # Get our machine object
        machine = machines[options.machine]
            
        # Ensure that a sensor config is defined
        if options.sensor_config is None:
            logger.error("A sensor config file must be defined for physical analysis")
            return
        # Get the list of sensors
        sensors = CONF.import_from_config(options.sensor_config, "sensor")
        
        # Add sensors to our machine
        print "* Trying to find physical sensors for %s..."%options.machine
        added_sensors = machine.add_sensors(sensors)
        
    else:
        machine = VirtualMachine(options.machine,
                                 vm_type=options.machine_type,
                                 volatility_profile=options.profile)
        
        
    
    ftp_info = {'user':G.FTP_USER,
                 'pass':G.FTP_PASSWORD,
                 'ip':ftp_ip,
                 'port':G.FTP_PORT,
                 'dir':None
                 }
    
    print "* Machine is: %s"%machine.power_status()
    
    ra = RemoteAnalysis(options.profile, machine.control, ftp_info)
        

        
    parameters = {
#                   1:'INTmark (write)',
#                   2:'INTmark (Read)',
                  3:'INTmem',
#                   4:'FLOATmark (write)',
#                   5:'FLOATmark (Read)',
                  6:'FLOATmem',
#                   7:'MMXmark (write)',
#                   8:'MMXmark (Read)',
                  9:'MMXmem',
#                   10:'SSEmark (write)',
#                   11:'SSEmark (Read)',
                  12:'SSEmem'
                  }
    # Create a run for all of our parameters (Only *mem will run in batches)
    for b_param in parameters:
        # Should we be reading memory?
        if options.enable_sensor:
            memory_thread = MemoryThread(machine)
            memory_thread.daemon = True
            memory_thread.start()
        
        param_name = parameters[b_param]
        
        print "* Running %s test, %d times..."%(param_name, 
                                                options.run_count)
        
        response = ra.run_analysis("ramspeed-win32.exe -b %d -l %d"%(
                                                        b_param,
                                                        options.run_count),
                                    "artifacts-memory",
                                    init_commands=[],
                                    bind_ip=ftp_ip)
        
        # Now store our results
        results_file = os.path.join(options.output_dir,
                                    "trial_b%d_l%d.txt"%(b_param,
                                                         options.run_count))
        sensor_file = os.path.join(options.output_dir,
                                    "trial_b%d_l%d_sensor.txt"%(b_param,
                                                         options.run_count))
        print "* Storing results (%d bytes) in %s."%(len(response),results_file)
        f = open(results_file, "w+")
        f.write(response)
        f.close()
    
        if options.enable_sensor:
            (time_elapsed, bytes_read) = memory_thread.join()
            f = open(sensor_file, "w+")
            f.write(str(time_elapsed)+"\t"+str(bytes_read))
            f.close()
def run_analysis(options):

    # Get our FTP IP
    try:
        ftp_ip = NET.get_ip_address(options.ftp_interface)
    except:
        logger.error("Could not find ip for the given interface. (%s)" %
                     options.ftp_interface)

    # Add a sensors to physical machines if needed
    if options.machine_type == G.MACHINE_TYPES.PHYSICAL:
        has_memory = has_disk = False

        if options.machine_config is None:
            logger.error("No machine config file given.")
            return

        # This isn't the class we use in practice, but fake it here for simplicity
        machines = CONF.import_from_config(options.machine_config, "machine")

        if options.machine not in machines:
            logger.error("%s is not a valid machine from the config file." %
                         options.machine)
            logger.error("Valid targets are: %s" % machines.keys())
            return

        # Get our machine object
        machine = machines[options.machine]

        # Ensure that a sensor config is defined
        if options.sensor_config is None:
            logger.error(
                "A sensor config file must be defined for physical analysis")
            return
        # Get the list of sensors
        sensors = CONF.import_from_config(options.sensor_config, "sensor")

        # Add sensors to our machine
        print "* Trying to find physical sensors for %s..." % options.machine
        added_sensors = machine.add_sensors(sensors)

    else:
        machine = VirtualMachine(options.machine,
                                 vm_type=options.machine_type,
                                 volatility_profile=options.profile)

    ftp_info = {
        'user': G.FTP_USER,
        'pass': G.FTP_PASSWORD,
        'ip': ftp_ip,
        'port': G.FTP_PORT,
        'dir': None
    }

    print "* Machine is: %s" % machine.power_status()

    ra = RemoteAnalysis(options.profile, machine.control, ftp_info)

    parameters = {
        #                   1:'INTmark (write)',
        #                   2:'INTmark (Read)',
        3: 'INTmem',
        #                   4:'FLOATmark (write)',
        #                   5:'FLOATmark (Read)',
        6: 'FLOATmem',
        #                   7:'MMXmark (write)',
        #                   8:'MMXmark (Read)',
        9: 'MMXmem',
        #                   10:'SSEmark (write)',
        #                   11:'SSEmark (Read)',
        12: 'SSEmem'
    }
    # Create a run for all of our parameters (Only *mem will run in batches)
    for b_param in parameters:
        # Should we be reading memory?
        if options.enable_sensor:
            memory_thread = MemoryThread(machine)
            memory_thread.daemon = True
            memory_thread.start()

        param_name = parameters[b_param]

        print "* Running %s test, %d times..." % (param_name,
                                                  options.run_count)

        response = ra.run_analysis("ramspeed-win32.exe -b %d -l %d" %
                                   (b_param, options.run_count),
                                   "artifacts-memory",
                                   init_commands=[],
                                   bind_ip=ftp_ip)

        # Now store our results
        results_file = os.path.join(
            options.output_dir,
            "trial_b%d_l%d.txt" % (b_param, options.run_count))
        sensor_file = os.path.join(
            options.output_dir,
            "trial_b%d_l%d_sensor.txt" % (b_param, options.run_count))
        print "* Storing results (%d bytes) in %s." % (len(response),
                                                       results_file)
        f = open(results_file, "w+")
        f.write(response)
        f.close()

        if options.enable_sensor:
            (time_elapsed, bytes_read) = memory_thread.join()
            f = open(sensor_file, "w+")
            f.write(str(time_elapsed) + "\t" + str(bytes_read))
            f.close()
Beispiel #3
0
def run_analysis(options):

    # Get our FTP IP
    try:
        ftp_ip = NET.get_ip_address(options.ftp_interface)
    except:
        logger.error("Could not find ip for the given interface. (%s)" %
                     options.ftp_interface)

    # Add a sensors to physical machines if needed
    if options.machine_type == G.MACHINE_TYPES.PHYSICAL:
        has_memory = has_disk = False

        if options.machine_config is None:
            logger.error("No machine config file given.")
            return

        # This isn't the class we use in practice, but fake it here for simplicity
        machines = CONF.import_from_config(options.machine_config, "machine")

        if options.machine not in machines:
            logger.error("%s is not a valid machine from the config file." %
                         options.machine)
            logger.error("Valid targets are: %s" % machines.keys())
            return

        # Get our machine object
        machine = machines[options.machine]

        # Ensure that a sensor config is defined
        if options.sensor_config is None:
            logger.error(
                "A sensor config file must be defined for physical analysis")
            return
        # Get the list of sensors
        sensors = CONF.import_from_config(options.sensor_config, "sensor")

        # Add sensors to our machine
        print "Trying to find physical sensors for %s..." % options.machine
        added_sensors = machine.add_sensors(sensors)

        if options.enable_sensor:
            machine.disk.sata_enable_all()

    else:
        machine = VirtualMachine(options.machine,
                                 vm_type=options.machine_type,
                                 volatility_profile=options.profile)

    ftp_info = {
        'user': G.FTP_USER,
        'pass': G.FTP_PASSWORD,
        'ip': ftp_ip,
        'port': G.FTP_PORT,
        'dir': None
    }

    print machine.power_status()

    ra = RemoteAnalysis(options.profile, machine.control, ftp_info)

    for trial in range(44, options.run_count):

        print "Running trial #%d..." % trial

        # Should we fire up our disk sensor?
        #         if options.enable_sensor:
        #             log_dcap_filename = os.path.join(options.output_dir,"trial_%d.dcap"%trial)
        #             log_dcap_queue = multiprocessing.Queue()
        #             log_dcap_writer = CaptureWriter(log_dcap_filename,
        #                                             log_dcap_queue)
        #             log_dcap_writer.start()
        #
        #             dcap_engine = DiskCaptureEngine(machine, log_dcap_queue)
        #             dcap_engine.start()

        iozone_cmd = "iozone.exe -a -g 2G -i 0 -i 1"
        response = ra.run_analysis(
            iozone_cmd,
            None,
            init_commands=["cd C:\Program Files\Benchmarks\Iozone3_414"],
            bind_ip=ftp_ip)

        f = open(os.path.join(options.output_dir, "trial_%d.txt" % trial),
                 "w+")
        f.write(response)
        f.close()

        #         if options.enable_sensor:
        #             dcap_engine.stop()
        #             log_dcap_writer.stop()

        print response
Beispiel #4
0
def run_analysis(options):

    # Get our FTP IP
    try:
        ftp_ip = NET.get_ip_address(options.ftp_interface)
    except:
        logger.error("Could not find ip for the given interface. (%s)"%
                     options.ftp_interface)
            
    # Add a sensors to physical machines if needed
    if options.machine_type == G.MACHINE_TYPES.PHYSICAL:
        has_memory = has_disk = False
        
        if options.machine_config is None:
            logger.error("No machine config file given.")
            return
        
        # This isn't the class we use in practice, but fake it here for simplicity
        machines = CONF.import_from_config(options.machine_config, "machine")
    
        if options.machine not in machines:
            logger.error("%s is not a valid machine from the config file."%options.machine)
            logger.error("Valid targets are: %s"%machines.keys())
            return

        # Get our machine object
        machine = machines[options.machine]
            
        # Ensure that a sensor config is defined
        if options.sensor_config is None:
            logger.error("A sensor config file must be defined for physical analysis")
            return
        # Get the list of sensors
        sensors = CONF.import_from_config(options.sensor_config, "sensor")
        
        # Add sensors to our machine
        print "Trying to find physical sensors for %s..."%options.machine
        added_sensors = machine.add_sensors(sensors)
        
        if options.enable_sensor:
            machine.disk.sata_enable_all()
        
    else:
        machine = VirtualMachine(options.machine,
                                 vm_type=options.machine_type,
                                 volatility_profile=options.profile)
        
        
    
    ftp_info = {'user':G.FTP_USER,
                 'pass':G.FTP_PASSWORD,
                 'ip':ftp_ip,
                 'port':G.FTP_PORT,
                 'dir':None
                 }
    
    print machine.power_status()
    
    ra = RemoteAnalysis(options.profile, machine.control, ftp_info)
    
    for trial in range(44,options.run_count):
        
        print "Running trial #%d..."%trial
        
        # Should we fire up our disk sensor?
#         if options.enable_sensor:
#             log_dcap_filename = os.path.join(options.output_dir,"trial_%d.dcap"%trial)
#             log_dcap_queue = multiprocessing.Queue()
#             log_dcap_writer = CaptureWriter(log_dcap_filename,
#                                             log_dcap_queue)
#             log_dcap_writer.start()
#             
#             dcap_engine = DiskCaptureEngine(machine, log_dcap_queue)
#             dcap_engine.start()
            
        iozone_cmd = "iozone.exe -a -g 2G -i 0 -i 1"
        response = ra.run_analysis(iozone_cmd,
                                     None,
                                     init_commands=["cd C:\Program Files\Benchmarks\Iozone3_414"],
                                     bind_ip=ftp_ip)

        f = open(os.path.join(options.output_dir,"trial_%d.txt"%trial), "w+")
        f.write(response)
        f.close()
        
#         if options.enable_sensor:
#             dcap_engine.stop()
#             log_dcap_writer.stop()
            
        print response