def compute_metrics(log_dir, bench, bench_type): dest_dir = log_dir + '/%d/' % bench['nb-hosts'] if bench_type == HM.CPU: results = results_cpu dest_dir = dest_dir + "/cpu" elif bench_type == HM.MEMORY: results = results_memory dest_dir = dest_dir + "/memory" try: if not os.path.isdir(dest_dir): os.makedirs(dest_dir) except OSError, e: HL.fatal_error("Cannot create %s directory (%s)" % (dest_dir, e.errno))
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'))
def prepare_metrics(log_dir, bench, bench_type): dest_dir = log_dir + '/%d/' % bench['nb-hosts'] if bench_type == HM.CPU: dest_dir = dest_dir + "/cpu-" + bench['name'] elif bench_type == HM.MEMORY: dest_dir = dest_dir + "/memory-" + bench['name'] elif bench_type == HM.NETWORK: dest_dir = dest_dir + "/network-" + bench['name'] elif bench_type == HM.STORAGE: dest_dir = dest_dir + "/storage-" + bench['name'] else: HL.fatal_error("Unknown benchmark type in prepare_metrics") try: if not os.path.isdir(dest_dir): os.makedirs(dest_dir) except OSError, e: HL.fatal_error("Cannot create %s directory (%s)" % (dest_dir, e.errno))
def compute_metrics(log_dir, bench, bench_type): dest_dir = log_dir + '/%d/' % bench['nb-hosts'] if bench_type == HM.CPU: results = results_cpu dest_dir = dest_dir + "/cpu-" + bench['name'] elif bench_type == HM.MEMORY: results = results_memory dest_dir = dest_dir + "/memory-" + bench['name'] elif bench_type == HM.NETWORK: results = results_network dest_dir = dest_dir + "/network-" + bench['name'] try: if not os.path.isdir(dest_dir): os.makedirs(dest_dir) except OSError, e: HL.fatal_error("Cannot create %s directory (%s)" % (dest_dir, e.errno))
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'))
def prepare_log_dir(name): config = ConfigParser.ConfigParser() config.read('/etc/edeploy.conf') def config_get(section, name, default): 'Secured config getter.' try: return config.get(section, name) except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): return default cfg_dir = os.path.normpath(config_get('SERVER', 'HEALTHDIR', '')) + '/' dirname = startup_date dest_dir = cfg_dir + 'dahc/%s/' % name + dirname try: if not os.path.isdir(dest_dir): os.makedirs(dest_dir) except OSError, e: HL.fatal_error("Cannot create %s directory (%s)" % (dest_dir, e.errno))
def prepare_log_dir(name): config = ConfigParser.ConfigParser() config.read('/etc/edeploy.conf') def config_get(section, name, default): 'Secured config getter.' try: return config.get(section, name) 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/%s/' % name + dirname try: if not os.path.isdir(dest_dir): os.makedirs(dest_dir) except OSError, e: HL.fatal_error("Cannot create %s directory (%s)" % (dest_dir, e.errno))