示例#1
0
def compute_metrics(dest_dir, bench, bench_type):
    if bench_type == HM.CPU:
        results = results_cpu
    elif bench_type == HM.MEMORY:
        results = results_memory
    elif bench_type == HM.NETWORK:
        results = results_network
    elif bench_type == HM.STORAGE:
        results = results_storage
    else:
        HL.fatal_error("Unknown benchmark type in compute_metrics")

    delta_start_jitter = {}
    duration = {}
    real_start = {}

    for host in results.keys():
        # Checking jitter settings
        if host not in start_jitter:
            HP.logger.error("Host %s should have a jitter value !" % host)
        else:
            if len(start_jitter[host]) < 2:
                HP.logger.error(
                    "Not enough start jitter information for host %s" % host)
            else:
                real_start[host] = start_jitter[host][1]
                delta_start_jitter[host] = (start_jitter[host][1] -
                                            start_jitter[host][0])
                duration[host] = (stop_jitter[host] - start_jitter[host][1])
                if (float(duration[host]) > float(bench['runtime'] + 1)):
                    HP.logger.error(
                        "Host %s took too much time : %.2f while expecting %d"
                        % (host, duration[host], bench['runtime']))

        HP.logger.debug("Dumping result from host %s" % str(host))
        filename_and_macs = HL.generate_filename_and_macs(results[host])
        save_hw(results[host], filename_and_macs['sysname'], dest_dir)

    output = {}
    output['bench'] = bench
    output['hosts'] = results.keys()
    output['affinity'] = dump_affinity(bench, bench_type)
    output['start_time'] = real_start
    output['start_lag'] = delta_start_jitter
    output['duration'] = duration
    pprint.pprint(output, stream=open(dest_dir + "/metrics", 'w'))
示例#2
0
def compute_metrics(dest_dir, bench, bench_type):
    if bench_type == HM.CPU:
        results = results_cpu
    elif bench_type == HM.MEMORY:
        results = results_memory
    elif bench_type == HM.NETWORK:
        results = results_network
    elif bench_type == HM.STORAGE:
        results = results_storage
    else:
        HL.fatal_error("Unknown benchmark type in compute_metrics")

    delta_start_jitter = {}
    duration = {}
    real_start = {}

    for host in results.keys():
        # Checking jitter settings
        if host not in start_jitter:
            HP.logger.error("Host %s should have a jitter value !" % host)
        else:
            if len(start_jitter[host]) < 2:
                HP.logger.error("Not enough start jitter information for host %s" % host)
            else:
                real_start[host] = start_jitter[host][1]
                delta_start_jitter[host] = (start_jitter[host][1] - start_jitter[host][0])
                duration[host] = (stop_jitter[host] - start_jitter[host][1])
                if (float(duration[host]) > float(bench['runtime'] + 1)):
                    HP.logger.error("Host %s took too much time : %.2f while expecting %d" % (host, duration[host], bench['runtime']))

        HP.logger.debug("Dumping result from host %s" % str(host))
        filename_and_macs = HL.generate_filename_and_macs(results[host])
        save_hw(results[host], filename_and_macs['sysname'], dest_dir)

    output = {}
    output['bench'] = bench
    output['hosts'] = results.keys()
    output['affinity'] = dump_affinity(bench, bench_type)
    output['start_time'] = real_start
    output['start_lag'] = delta_start_jitter
    output['duration'] = duration
    pprint.pprint(output, stream=open(dest_dir+"/metrics", 'w'))
示例#3
0
        except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
            return default

    cfg_dir = os.path.normpath(config_get('SERVER', 'HEALTHDIR', '')) + '/'
    dirname = time.strftime("%Y_%m_%d-%Hh%M", time.localtime())
    dest_dir = cfg_dir + 'dahc/%d/' % nb_hosts + dirname

    try:
        if not os.path.isdir(dest_dir):
            os.makedirs(dest_dir)
    except OSError, e:
        fatal_error("Cannot create %s directory (%s)" % (dest_dir, e.errno))

    for host in results_cpu.keys():
        HP.logger.info("Dumping cpu result from host %s" % str(host))
        filename_and_macs = HL.generate_filename_and_macs(results_cpu[host])
        save_hw(results_cpu[host], filename_and_macs['sysname'], dest_dir)
#        print results_cpu[host]


def get_default_value(job, item, default_value):
    return job.get(item, default_value)


def non_interactive_mode(filename):
    total_runtime = 0
    name = "undefined"

    job = yaml.load(file(filename, 'r'))
    if job['name'] is None:
        HP.logger.error("Missing name parameter in yaml file")
示例#4
0
        else:
            if len(start_jitter[host]) < 2:
                HP.logger.error(
                    "Not enough start jitter information for host %s" % host)
            else:
                real_start[host] = start_jitter[host][1]
                delta_start_jitter[host] = (start_jitter[host][1] -
                                            start_jitter[host][0])
                duration[host] = (stop_jitter[host] - start_jitter[host][1])
                if (float(duration[host]) > float(bench['runtime'] + 1)):
                    HP.logger.error(
                        "Host %s took too much time : %.2f while expecting %d"
                        % (host, duration[host], bench['runtime']))

        HP.logger.debug("Dumping result from host %s" % str(host))
        filename_and_macs = HL.generate_filename_and_macs(results[host])
        save_hw(results[host], filename_and_macs['sysname'], dest_dir)

    output = {}
    output['bench'] = bench
    output['hosts'] = results.keys()
    output['affinity'] = dump_affinity(bench, bench_type)
    output['start_time'] = real_start
    output['start_lag'] = delta_start_jitter
    output['duration'] = duration
    pprint.pprint(output, stream=open(dest_dir + "/metrics", 'w'))


def get_default_value(job, item, default_value):
    return job.get(item, default_value)