def show_diff_edges(ns): conf_fn1, conf_fn2 = ns.confs conf1 = arguments.open_logdag_config(conf_fn1) conf2 = arguments.open_logdag_config(conf_fn2) lv = logging.DEBUG if ns.debug else logging.INFO am_logger = logging.getLogger("amulog") config.set_common_logging(conf1, logger=[_logger, am_logger], lv=lv) from . import comparison am = arguments.ArgumentManager(conf1) am.load() for dt_range in sorted(am.iter_dt_range()): cevmap, cgraph = comparison.edge_set_diff(conf1, conf2, dt_range) buf_edges = [] for edge in cgraph.edges(): buf = "" src_info = cevmap.evdef(edge[0]) buf += "[gid={0[0]}, host = {0[1]}]".format(src_info) if showdag.isdirected(edge, cgraph): buf += " -> " else: buf += " <-> " dst_info = cevmap.evdef(edge[1]) buf += "[gid={0[0]}, host = {0[1]}]".format(dst_info) buf_edges.append(buf) if len(buf_edges) > 0: print("date: {0}".format(dt_range[0])) print("\n".join(buf_edges))
def show_diff_direction(ns): conf_fn1, conf_fn2 = ns.confs conf1 = arguments.open_logdag_config(conf_fn1) conf2 = arguments.open_logdag_config(conf_fn2) lv = logging.DEBUG if ns.debug else logging.INFO am_logger = logging.getLogger("amulog") config.set_common_logging(conf1, logger=[_logger, am_logger], lv=lv) def _print_diff(_ret): for ev1, ev2, di1, di2 in _ret: print("{0} {1} | {2} {3}".format(ev1, di1, di2, ev2)) cnt = 0 from . import comparison am = arguments.ArgumentManager(conf1) am.load() if ns.argname is None: for dt_range in sorted(am.iter_dt_range()): ret = comparison.edge_direction_diff(conf1, conf2, dt_range) cnt += len(ret) if len(ret) > 0: print(dt_range) _print_diff(ret) print("") else: args = am.jobname2args(ns.argname, conf1) dt_range = args[2] ret = comparison.edge_direction_diff(conf1, conf2, dt_range) cnt += len(ret) _print_diff(ret) print(cnt)
def show_diff_info(ns): conf_fn1, conf_fn2 = ns.confs conf1 = arguments.open_logdag_config(conf_fn1) conf2 = arguments.open_logdag_config(conf_fn2) lv = logging.DEBUG if ns.debug else logging.INFO am_logger = logging.getLogger("amulog") config.set_common_logging(conf1, logger=[_logger, am_logger], lv=lv) from . import comparison d = defaultdict(int) am = arguments.ArgumentManager(conf1) am.load() for dt_range in am.iter_dt_range(): cevmap_common, cgraph_common = comparison.edge_set_common( conf1, conf2, dt_range) d["common"] += cgraph_common.number_of_edges() cevmap_lor, cgraph_lor = comparison.edge_set_lor( conf1, conf2, dt_range) d["lor"] += cgraph_lor.number_of_edges() cevmap_diff1, cgraph_diff1 = comparison.edge_set_diff(conf1, conf2, dt_range, lor=(cevmap_lor, cgraph_lor)) d["diff1"] += cgraph_diff1.number_of_edges() cevmap_diff2, cgraph_diff2 = comparison.edge_set_diff(conf2, conf1, dt_range, lor=(cevmap_lor, cgraph_lor)) d["diff2"] += cgraph_diff2.number_of_edges() print("Logical OR edges: {0}".format(d["lor"])) print("Common edges: {0}".format(d["common"])) print("Edges only found in {0}: {1}".format(ns.confs[0], d["diff1"])) print("Edges only found in {0}: {1}".format(ns.confs[1], d["diff2"]))
def show_graph_diff_search(ns): conf_fn1, conf_fn2 = ns.confs conf1 = arguments.open_logdag_config(conf_fn1) conf2 = arguments.open_logdag_config(conf_fn2) lv = logging.DEBUG if ns.debug else logging.INFO am_logger = logging.getLogger("amulog") config.set_common_logging(conf1, logger=[_logger, am_logger], lv=lv) gid = ns.gid from . import comparison comparison.edge_diff_gid_search(conf1, conf2, gid)
def show_graph_diff_lts(ns): conf_fn1, conf_fn2 = ns.confs conf1 = arguments.open_logdag_config(conf_fn1) conf2 = arguments.open_logdag_config(conf_fn2) lv = logging.DEBUG if ns.debug else logging.INFO am_logger = logging.getLogger("amulog") config.set_common_logging(conf1, logger=[_logger, am_logger], lv=lv) from amulog import log_db ld = log_db.LogData(conf1) from . import comparison d_ltid = comparison.edge_diff_gid(conf1, conf2) for ltid, l_name in sorted(d_ltid.items(), key=lambda x: len(x[1]), reverse=True): print("{0}: {1} ({2})".format(len(l_name), ltid, ld.lt(ltid))) if len(l_name) < 100: print(l_name)
def draw_graph_diff(ns): conf_fn1, conf_fn2 = ns.confs conf1 = arguments.open_logdag_config(conf_fn1) conf2 = arguments.open_logdag_config(conf_fn2) lv = logging.DEBUG if ns.debug else logging.INFO am_logger = logging.getLogger("amulog") config.set_common_logging(conf1, logger=[_logger, am_logger], lv=lv) dts = dtutil.shortstr2dt(ns.timestr) dte = dts + config.getdur(conf1, "dag", "unit_term") output = ns.filename from . import comparison cevmap, cgraph = comparison.edge_set_diff(conf1, conf2, (dts, dte)) from . import draw rgraph = draw.relabel_nodes(cgraph, cevmap) draw.graph_nx(output, rgraph) print(output)
def show_graph_lor_edges(ns): conf_fn1, conf_fn2 = ns.confs conf1 = arguments.open_logdag_config(conf_fn1) conf2 = arguments.open_logdag_config(conf_fn2) lv = logging.DEBUG if ns.debug else logging.INFO am_logger = logging.getLogger("amulog") config.set_common_logging(conf1, logger=[_logger, am_logger], lv=lv) from . import comparison edge_sum = 0 d_edges = {} am = arguments.ArgumentManager(conf1) am.load() for dt_range in am.iter_dt_range(): cevmap, cgraph = comparison.edge_set_lor(conf1, conf2, dt_range) edge_sum += cgraph.number_of_edges() d_edges[dt_range[0]] = cgraph.edges() print("logical disjunction edge num: {0}".format(edge_sum)) for k, v in sorted(d_edges.items(), key=lambda x: x[0]): print("{0}: {1}".format(k, len(v)))
def open_logdag_config(ns): from logdag import arguments return arguments.open_logdag_config(ns.conf_path, debug=ns.debug)
""" import sys import datetime from tqdm import tqdm FAILURE_OUTPUT = "migrate_failure.txt" if __name__ == "__main__": if len(sys.argv) < 3: sys.exit("usage: {0} CONF1 CONF2".format(sys.argv[0])) from logdag import arguments conf1 = arguments.open_logdag_config(sys.argv[1]) conf2 = arguments.open_logdag_config(sys.argv[2]) from amulog import config from amulog import log_db amulog_conf1 = config.open_config(conf1["database_amulog"]["source_conf"]) ld1 = log_db.LogData(amulog_conf1) amulog_conf2 = config.open_config(conf2["database_amulog"]["source_conf"]) ld2 = log_db.LogData(amulog_conf2) from logdag.eval import trouble dirname1 = conf1.get("eval", "path") dirname2 = conf2.get("eval", "path") tm1 = trouble.TroubleManager(dirname1) tm2 = trouble.TroubleManager(dirname2)