예제 #1
0
def parse_oniontrace_logs(args):
    otracetools_exe = which('oniontracetools')

    if otracetools_exe == None:
        logging.warning(
            "Cannot find oniontracetools in your PATH. Is your python venv active? Do you have oniontracetools installed?"
        )
        logging.warning("Unable to parse oniontrace simulation data.")
        return

    cmd_str = f"{otracetools_exe} parse -m {args.nprocesses} -e '.*\.oniontrace\.[0-9]+.stdout' shadow.data/hosts"
    cmd = cmdsplit(cmd_str)

    datestr = datetime.datetime.now().strftime("%Y-%m-%d.%H:%M:%S")

    with open_writeable_file(
            f"{args.prefix}/oniontracetools.parse.{datestr}.log") as outf:
        logging.info("Parsing oniontrace log data with oniontracetools now...")
        comproc = subprocess.run(cmd,
                                 cwd=args.prefix,
                                 stdout=outf,
                                 stderr=subprocess.STDOUT)
        logging.info(f"oniontracetools returned code {comproc.returncode}")

    return comproc.returncode == 0
예제 #2
0
def parse_tgen_logs(args):
    tgentools_exe = which('tgentools')

    if tgentools_exe == None:
        logging.warning(
            "Cannot find tgentools in your PATH. Is your python venv active? Do you have tgentools installed?"
        )
        logging.warning("Unable to parse tgen simulation data.")
        return

    cmd_str = f"{tgentools_exe} parse -m {args.nprocesses} -e 'perfclient[0-9]+\.tgen\.[0-9]+.stdout' --complete shadow.data/hosts"
    cmd = cmdsplit(cmd_str)

    datestr = datetime.datetime.now().strftime("%Y-%m-%d.%H:%M:%S")

    with open_writeable_file(
            f"{args.prefix}/tgentools.parse.{datestr}.log") as outf:
        logging.info("Parsing tgen log data with tgentools now...")
        comproc = subprocess.run(cmd,
                                 cwd=args.prefix,
                                 stdout=outf,
                                 stderr=subprocess.STDOUT)
        logging.info(f"tgentools returned code {comproc.returncode}")

    return comproc.returncode == 0
예제 #3
0
def plot_oniontrace(args):
    oniontracetools_exe = which('oniontracetools')

    if oniontracetools_exe == None:
        logging.warning(
            "Cannot find oniontracetools in your PATH. Is your python venv active? Do you have oniontracetools installed?"
        )
        logging.warning("Unable to plot oniontrace data.")
        return

    # plot the tgen simulation data for each tgen json file in the tornet path
    cmd_prefix_str = f"{oniontracetools_exe} plot --expression 'relay|4uthority' --prefix 'relays'"
    for collection in args.tornet_collection_path:
        for json_path in find_matching_files_in_dir(
                collection, "oniontrace.analysis.json"):
            dir_path = os.path.dirname(json_path)
            dir_name = os.path.basename(dir_path)

            cmd_str = f"{cmd_prefix_str} --data {json_path} {dir_name}"
            cmd = cmdsplit(cmd_str)

            datestr = datetime.datetime.now().strftime("%Y-%m-%d.%H:%M:%S")

            with open_writeable_file(
                    f"{dir_path}/oniontracetools.plot.{datestr}.log") as outf:
                logging.info(
                    f"Using oniontracetools to plot data from {json_path} now..."
                )
                comproc = subprocess.run(cmd,
                                         cwd=dir_path,
                                         stdout=outf,
                                         stderr=subprocess.STDOUT)
                logging.info(
                    f"oniontracetools returned code {comproc.returncode}")
예제 #4
0
def __run_shadow(args):
    shadow_exe_path = which('shadow')
    if shadow_exe_path == None:
        logging.warning(
            "Cannot find shadow in your PATH. Do you have shadow installed (e.g., in ~/.shadow/bin)? Did you update your PATH?"
        )
        logging.warning("Unable to run simulation without shadow.")
        return None

    with open_writeable_file(f"{args.prefix}/shadow.log",
                             compress=args.do_compress) as outf:
        shadow_cmd = cmdsplit(
            f"{shadow_exe_path} {args.shadow_args} shadow.config.xml")
        comproc = subprocess.run(shadow_cmd, cwd=args.prefix, stdout=outf)

    return comproc
예제 #5
0
def __run_shadow(args):
    shadow_exe_path = args.shadowexe
    if shadow_exe_path == None:
        logging.warning(
            "Cannot find shadow in your PATH. Do you have shadow installed (e.g., in ~/.shadow/bin)? Did you update your PATH?"
        )
        logging.warning("Unable to run simulation without shadow.")
        return None

    cmd_prefix = "/usr/bin/chrt -f 1 " if args.use_realtime else ""
    args_suffix = " --template-directory=shadow.data.template" if '--template-directory' not in args.shadow_args else ""

    shadow_args = args.shadow_args
    with open_writeable_file(f"{args.prefix}/shadow.log",
                             compress=args.do_compress) as outf:
        shadow_cmd = cmdsplit(
            f"{cmd_prefix}{shadow_exe_path} {shadow_args}{args_suffix} shadow.config.yaml"
        )
        comproc = subprocess.run(shadow_cmd, cwd=args.prefix, stdout=outf)

    return comproc