Esempio n. 1
0
def start_tcpdump_collector(instance_id: int, outdir: str) -> subprocess.Popen:
    domid = get_domid_from_instance_id(instance_id)

    try:
        subprocess.check_output("tcpdump --version", shell=True)
    except subprocess.CalledProcessError:
        raise RuntimeError("Failed to start tcpdump")

    return subprocess.Popen(
        ["tcpdump", "-i", f"vif{domid}.0-emu", "-w", f"{outdir}/dump.pcap"])
Esempio n. 2
0
def start_tcpdump_collector(instance_id: str, outdir: str) -> Optional[subprocess.Popen]:
    domid = get_domid_from_instance_id(instance_id)

    try:
        subprocess.check_output("tcpdump --version", shell=True)
    except subprocess.CalledProcessError:
        logging.warning("Seems like tcpdump is not working/not installed on your system. Pcap will not be recorded.")
        return None

    return subprocess.Popen([
        "tcpdump",
        "-i",
        f"vif{domid}.0-emu",
        "-w",
        f"{outdir}/dump.pcap"
    ])