From 8056c29485f41ba19a0a48f38de480b0f878741f Mon Sep 17 00:00:00 2001 From: nblair2 <134428428+nblair2@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:05:53 -0600 Subject: [PATCH] fix(tcpdump): use interface-specific name for pcap files This adds interface-specific pcap output file names to the tcpdump component to allow for multiple concurrent captures on the same VM but different interfaces. fixes #35 --- .../phenix_apps/apps/scorch/tcpdump/tcpdump.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/python/phenix_apps/apps/scorch/tcpdump/tcpdump.py b/src/python/phenix_apps/apps/scorch/tcpdump/tcpdump.py index fb5b499..28613bf 100644 --- a/src/python/phenix_apps/apps/scorch/tcpdump/tcpdump.py +++ b/src/python/phenix_apps/apps/scorch/tcpdump/tcpdump.py @@ -44,7 +44,7 @@ def start(self): mm.cc_filter(f'name={hostname}') mm.cc_exec(f'ip link set {iface} up') - mm.cc_background(f'tcpdump {options} -i {iface} -U -w /dump.pcap {filter}') + mm.cc_background(f'tcpdump {options} -i {iface} -U -w /dump-{iface}.pcap {filter}') logger.log('INFO', f'Started user component: {self.name}') @@ -65,20 +65,25 @@ def stop(self): for vm in vms: hostname = vm.get('hostname', None) + iface = vm.get('iface', None) if not hostname: self.eprint('no hostname provided for VM config') sys.exit(1) - pcap_out = f'{self.base_dir}/{hostname}.pcap' - json_out = f'{self.base_dir}/{hostname}.pcap.jsonl' + if not iface: + self.eprint('no interface name provided for VM config') + sys.exit(1) + + pcap_out = f'{self.base_dir}/{hostname}-{iface}.pcap' + json_out = f'{self.base_dir}/{hostname}-{iface}.pcap.jsonl' utils.mm_exec_wait(mm, hostname, 'pkill tcpdump') self.print(f'copying PCAP file from node {hostname}...') - utils.mm_recv(mm, hostname, '/dump.pcap', pcap_out) - mm.cc_exec('rm /dump.pcap') + utils.mm_recv(mm, hostname, f'/dump-{iface}.pcap', pcap_out) + mm.cc_exec(f'rm /dump-{iface}.pcap') self.print(f'done copying PCAP file from node {hostname}')