Ejemplo n.º 1
0
def stop_tcpdump(file_prefix='', remote_dir='', local_dir='.'):
    "Stop tcpdump instance on host"

    pid = bgproc.get_proc_pid(env.host_string, 'tcpdump', '0')
    with settings(warn_only=True):
        if pid != "":
            run('kill %s' % pid, pty=False)
        else:
            # get host type
            htype = get_type_cached(env.host_string)
            if htype == "FreeBSD" or htype == "Linux" or htype == 'Darwin':
                run('killall tcpdump')
            else:
                run('killall WinDump', pty=False)

    if file_prefix != "" or remote_dir != "":
        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + ".dmp"
    else:
        file_name = bgproc.get_proc_log(env.host_string, 'tcpdump', '0')

    getfile(file_name, local_dir)
    bgproc.remove_proc(env.host_string, 'tcpdump', '0')
Ejemplo n.º 2
0
def stop_tcpdump(file_prefix='', remote_dir='', local_dir='.'):
    "Stop tcpdump instance on host"

    pid = bgproc.get_proc_pid(env.host_string, 'tcpdump', '0')
    with settings(warn_only=True):
        if pid != "":
            run('kill %s' % pid, pty=False)
        else:
            # get host type
            htype = get_type_cached(env.host_string)
            if htype == "FreeBSD" or htype == "Linux" or htype == 'Darwin':
                run('killall tcpdump')
            else:
                run('killall WinDump', pty=False)

    if file_prefix != "" or remote_dir != "":
        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + ".dmp"
    else:
        file_name = bgproc.get_proc_log(env.host_string, 'tcpdump', '0')

    getfile(file_name, local_dir)
    bgproc.remove_proc(env.host_string, 'tcpdump', '0')