diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/automation/regression/functional_tests/trex_cfg_creator_test.py | 64 | ||||
-rw-r--r-- | scripts/automation/regression/setups/kiwi02/benchmark.yaml | 50 | ||||
-rw-r--r-- | scripts/automation/regression/setups/trex-dan/config.yaml | 4 | ||||
-rw-r--r-- | scripts/automation/regression/setups/trex09/benchmark.yaml | 2 | ||||
-rw-r--r-- | scripts/automation/regression/setups/trex25/config.yaml | 16 | ||||
-rw-r--r-- | scripts/automation/regression/stateless_tests/stl_performance_test.py | 4 | ||||
-rwxr-xr-x | scripts/automation/regression/trex_unit_test.py | 2 | ||||
-rwxr-xr-x | scripts/dpdk_nic_bind.py | 15 | ||||
-rwxr-xr-x | scripts/dpdk_setup_ports.py | 112 | ||||
-rwxr-xr-x | scripts/find_python.sh | 51 | ||||
-rw-r--r-- | scripts/libzmq.so.3 | bin | 3150071 -> 3148890 bytes | |||
-rwxr-xr-x | scripts/trex_show_threads.py | 80 |
12 files changed, 266 insertions, 134 deletions
diff --git a/scripts/automation/regression/functional_tests/trex_cfg_creator_test.py b/scripts/automation/regression/functional_tests/trex_cfg_creator_test.py index ab6ab6f6..5ff6b318 100755 --- a/scripts/automation/regression/functional_tests/trex_cfg_creator_test.py +++ b/scripts/automation/regression/functional_tests/trex_cfg_creator_test.py @@ -102,10 +102,10 @@ class TRexCfgCreator_Test: version: 2 interfaces: ['0b:00.0', '03:00.0'] port_info: - - dest_mac: [0x00, 0x0c, 0x29, 0x92, 0xf1, 0xca] # MAC OF LOOPBACK TO IT'S DUAL INTERFACE - src_mac: [0x00, 0x0c, 0x29, 0x92, 0xf1, 0xd4] - - dest_mac: [0x00, 0x0c, 0x29, 0x92, 0xf1, 0xd4] - src_mac: [0x00, 0x0c, 0x29, 0x92, 0xf1, 0xca] + - dest_mac: 00:0c:29:92:f1:ca # MAC OF LOOPBACK TO IT'S DUAL INTERFACE + src_mac: 00:0c:29:92:f1:d4 + - dest_mac: 00:0c:29:92:f1:d4 + src_mac: 00:0c:29:92:f1:ca platform: master_thread_id: 0 @@ -291,20 +291,20 @@ class TRexCfgCreator_Test: interfaces: ['02:00.0', '02:00.1', '84:00.0', '84:00.1', '05:00.0', '05:00.1'] port_bandwidth_gb: 40 port_info: - - dest_mac: [0x02, 0x00, 0x02, 0x00, 0x00, 0x00] - src_mac: [0x01, 0x00, 0x01, 0x00, 0x00, 0x00] - - dest_mac: [0x01, 0x00, 0x01, 0x00, 0x00, 0x00] - src_mac: [0x02, 0x00, 0x02, 0x00, 0x00, 0x00] + - dest_mac: 02:00:02:00:00:00 + src_mac: 01:00:01:00:00:00 + - dest_mac: 01:00:01:00:00:00 + src_mac: 02:00:02:00:00:00 - - dest_mac: [0x04, 0x00, 0x04, 0x00, 0x00, 0x00] - src_mac: [0x03, 0x00, 0x03, 0x00, 0x00, 0x00] - - dest_mac: [0x03, 0x00, 0x03, 0x00, 0x00, 0x00] - src_mac: [0x04, 0x00, 0x04, 0x00, 0x00, 0x00] + - dest_mac: 04:00:04:00:00:00 + src_mac: 03:00:03:00:00:00 + - dest_mac: 03:00:03:00:00:00 + src_mac: 04:00:04:00:00:00 - - dest_mac: [0x06, 0x00, 0x06, 0x00, 0x00, 0x00] - src_mac: [0x05, 0x00, 0x05, 0x00, 0x00, 0x00] - - dest_mac: [0x05, 0x00, 0x05, 0x00, 0x00, 0x00] - src_mac: [0x06, 0x00, 0x06, 0x00, 0x00, 0x00] + - dest_mac: 06:00:06:00:00:00 + src_mac: 05:00:05:00:00:00 + - dest_mac: 05:00:05:00:00:00 + src_mac: 06:00:06:00:00:00 platform: master_thread_id: 0 @@ -431,15 +431,15 @@ class TRexCfgCreator_Test: interfaces: ['02:00.0', '02:00.1', '84:00.0', '84:00.1'] port_bandwidth_gb: 40 port_info: - - dest_mac: [0x02, 0x00, 0x02, 0x00, 0x00, 0x00] - src_mac: [0x01, 0x00, 0x01, 0x00, 0x00, 0x00] - - dest_mac: [0x01, 0x00, 0x01, 0x00, 0x00, 0x00] - src_mac: [0x02, 0x00, 0x02, 0x00, 0x00, 0x00] + - dest_mac: 02:00:02:00:00:00 + src_mac: 01:00:01:00:00:00 + - dest_mac: 01:00:01:00:00:00 + src_mac: 02:00:02:00:00:00 - - dest_mac: [0x04, 0x00, 0x04, 0x00, 0x00, 0x00] - src_mac: [0x03, 0x00, 0x03, 0x00, 0x00, 0x00] - - dest_mac: [0x03, 0x00, 0x03, 0x00, 0x00, 0x00] - src_mac: [0x04, 0x00, 0x04, 0x00, 0x00, 0x00] + - dest_mac: 04:00:04:00:00:00 + src_mac: 03:00:03:00:00:00 + - dest_mac: 03:00:03:00:00:00 + src_mac: 04:00:04:00:00:00 platform: master_thread_id: 0 @@ -563,15 +563,15 @@ class TRexCfgCreator_Test: interfaces: ['02:00.0', '02:00.1', '05:00.0', '05:00.1'] port_bandwidth_gb: 40 port_info: - - dest_mac: [0x02, 0x00, 0x02, 0x00, 0x00, 0x00] - src_mac: [0x01, 0x00, 0x01, 0x00, 0x00, 0x00] - - dest_mac: [0x01, 0x00, 0x01, 0x00, 0x00, 0x00] - src_mac: [0x02, 0x00, 0x02, 0x00, 0x00, 0x00] + - dest_mac: 02:00:02:00:00:00 + src_mac: 01:00:01:00:00:00 + - dest_mac: 01:00:01:00:00:00 + src_mac: 02:00:02:00:00:00 - - dest_mac: [0x04, 0x00, 0x04, 0x00, 0x00, 0x00] - src_mac: [0x03, 0x00, 0x03, 0x00, 0x00, 0x00] - - dest_mac: [0x03, 0x00, 0x03, 0x00, 0x00, 0x00] - src_mac: [0x04, 0x00, 0x04, 0x00, 0x00, 0x00] + - dest_mac: 04:00:04:00:00:00 + src_mac: 03:00:03:00:00:00 + - dest_mac: 03:00:03:00:00:00 + src_mac: 04:00:04:00:00:00 platform: master_thread_id: 0 diff --git a/scripts/automation/regression/setups/kiwi02/benchmark.yaml b/scripts/automation/regression/setups/kiwi02/benchmark.yaml index e6621085..41688906 100644 --- a/scripts/automation/regression/setups/kiwi02/benchmark.yaml +++ b/scripts/automation/regression/setups/kiwi02/benchmark.yaml @@ -246,3 +246,53 @@ test_CPU_benchmark: bw_per_core : 1 + +test_performance_vm_single_cpu: + cfg: + mult : "90%" + mpps_per_core_golden : + min: 11.5 + max: 13.1 + + +test_performance_vm_single_cpu_cached: + cfg: + mult : "90%" + mpps_per_core_golden : + min: 22.0 + max: 25.0 + + + +test_performance_syn_attack_single_cpu: + cfg: + mult : "90%" + mpps_per_core_golden : + min: 9.5 + max: 11.5 + +test_performance_vm_multi_cpus: + cfg: + core_count : 4 + mult : "90%" + mpps_per_core_golden : + min: 9.7 + max: 12.5 + + +test_performance_vm_multi_cpus_cached: + cfg: + core_count : 4 + mult : "90%" + mpps_per_core_golden : + min: 19.0 + max: 22.0 + +test_performance_syn_attack_multi_cpus: + cfg: + core_count : 4 + mult : "90%" + mpps_per_core_golden : + min: 8.5 + max: 10.5 + diff --git a/scripts/automation/regression/setups/trex-dan/config.yaml b/scripts/automation/regression/setups/trex-dan/config.yaml index d147502f..fbed3cb7 100644 --- a/scripts/automation/regression/setups/trex-dan/config.yaml +++ b/scripts/automation/regression/setups/trex-dan/config.yaml @@ -54,11 +54,11 @@ router: - client : name : GigabitEthernet0/0/1 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f20.e6ce server : name : GigabitEthernet0/0/2 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f20.e6cf vrf_name : null tftp: diff --git a/scripts/automation/regression/setups/trex09/benchmark.yaml b/scripts/automation/regression/setups/trex09/benchmark.yaml index 86f169ed..d1f5f56c 100644 --- a/scripts/automation/regression/setups/trex09/benchmark.yaml +++ b/scripts/automation/regression/setups/trex09/benchmark.yaml @@ -204,7 +204,7 @@ test_performance_syn_attack_single_cpu: cfg: mult : "90%" mpps_per_core_golden : - min: 13.8 + min: 12.9 max: 14.5 test_performance_vm_multi_cpus: diff --git a/scripts/automation/regression/setups/trex25/config.yaml b/scripts/automation/regression/setups/trex25/config.yaml index c4b3743d..c8190636 100644 --- a/scripts/automation/regression/setups/trex25/config.yaml +++ b/scripts/automation/regression/setups/trex25/config.yaml @@ -52,38 +52,38 @@ router: - client : name : GigabitEthernet0/1/0 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6a3c server : name : GigabitEthernet0/1/1 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6a3d vrf_name : - client : name : GigabitEthernet0/1/2 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6a3e server : name : GigabitEthernet0/1/4 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6a3f vrf_name : - client : name : GigabitEthernet0/1/5 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6b78 server : name : GigabitEthernet0/1/3 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6b79 vrf_name : - client : name : GigabitEthernet0/1/6 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6b7a server : name : GigabitEthernet0/1/7 src_mac_addr : 0000.0001.0000 - dest_ipv6_mac_addr : 0000.0001.0000 + dest_ipv6_mac_addr : a036.9f4d.6b7b vrf_name : tftp: diff --git a/scripts/automation/regression/stateless_tests/stl_performance_test.py b/scripts/automation/regression/stateless_tests/stl_performance_test.py index 62a1912f..a556daf3 100644 --- a/scripts/automation/regression/stateless_tests/stl_performance_test.py +++ b/scripts/automation/regression/stateless_tests/stl_performance_test.py @@ -61,7 +61,7 @@ class PerformanceReport(object): SetupName = self.machine_name, TestType = 'performance', Mppspc = self.avg_mpps_per_core, - ActionNumber = '<fill_me>', + ActionNumber = os.getenv("BUILD_ID","n/a"), GoldenMin = golden_mpps['min'], GoldenMax = golden_mpps['max']) @@ -322,7 +322,7 @@ class STLPerformance_Test(CStlGeneral_Test): - avg_values = {k:avg(v) for k, v in samples.iteritems()} + avg_values = {k:avg(v) for k, v in samples.items()} avg_cpu = avg_values['cpu'] * scenario_cfg['core_count'] avg_gbps = avg_values['bps'] / 1e9 avg_mpps = avg_values['pps'] / 1e6 diff --git a/scripts/automation/regression/trex_unit_test.py b/scripts/automation/regression/trex_unit_test.py index 7a6c4260..daa1abaf 100755 --- a/scripts/automation/regression/trex_unit_test.py +++ b/scripts/automation/regression/trex_unit_test.py @@ -270,7 +270,7 @@ class CTRexTestConfiguringPlugin(Plugin): def finalize(self, result): if self.functional or self.collect_only: return - CTRexScenario.is_init = False + #CTRexScenario.is_init = False if self.stateful: CTRexScenario.trex = None if self.stateless: diff --git a/scripts/dpdk_nic_bind.py b/scripts/dpdk_nic_bind.py index a85ecb71..36d123f1 100755 --- a/scripts/dpdk_nic_bind.py +++ b/scripts/dpdk_nic_bind.py @@ -609,7 +609,7 @@ def get_info_from_trex(pci_addr_list): pci_info_dict[pci]['TRex_Driver'] = match.group(3) return pci_info_dict -def show_table(): +def show_table(get_macs = True): '''Function called when the script is passed the "--table" option. Similar to show_status() function, but shows more info: NUMA etc.''' global dpdk_drivers @@ -620,12 +620,13 @@ def show_table(): if devices[d].get("Driver_str") in dpdk_drivers: dpdk_drv.append(d) - for pci, info in get_info_from_trex(dpdk_drv).items(): - if pci not in dpdk_drv: # sanity check, should not happen - print('Internal error while getting MACs of DPDK bound interfaces, unknown PCI: %s' % pci) - return - devices[pci].update(info) - + if get_macs: + for pci, info in get_info_from_trex(dpdk_drv).items(): + if pci not in dpdk_drv: # sanity check, should not happen + print('Internal error while getting MACs of DPDK bound interfaces, unknown PCI: %s' % pci) + return + devices[pci].update(info) + table = texttable.Texttable(max_width=-1) table.header(['ID', 'NUMA', 'PCI', 'MAC', 'Name', 'Driver', 'Linux IF', 'Active']) for id, pci in enumerate(sorted(devices.keys())): diff --git a/scripts/dpdk_setup_ports.py b/scripts/dpdk_setup_ports.py index 5bbbdb28..f85dae5d 100755 --- a/scripts/dpdk_setup_ports.py +++ b/scripts/dpdk_setup_ports.py @@ -93,16 +93,15 @@ class ConfigCreator(object): self.ignore_numa = ignore_numa @staticmethod - def _convert_mac(mac_string): + def verify_mac(mac_string): if not ConfigCreator.mac_re.match(mac_string): raise DpdkSetup('MAC address should be in format of 12:34:56:78:9a:bc, got: %s' % mac_string) - return ', '.join([('0x%s' % elem).lower() for elem in mac_string.split(':')]) + return mac_string.lower() @staticmethod def _exit_if_bad_ip(ip): if not ConfigCreator._verify_ip(ip): - print("Got bad IP %s" % ip) - sys.exit(1) + raise DpdkSetup("Got bad IP %s" % ip) @staticmethod def _verify_ip(ip): @@ -146,12 +145,12 @@ class ConfigCreator(object): config_str += ' '*6 + '- ip: %s\n' % interface['ip'] config_str += ' '*8 + 'default_gw: %s\n' % interface['def_gw'] else: - config_str += ' '*6 + '- dest_mac: [%s]' % self._convert_mac(interface['dest_mac']) + config_str += ' '*6 + '- dest_mac: %s' % self.verify_mac(interface['dest_mac']) if interface.get('loopback_dest'): config_str += " # MAC OF LOOPBACK TO IT'S DUAL INTERFACE\n" else: config_str += '\n' - config_str += ' '*8 + 'src_mac: [%s]\n' % self._convert_mac(interface['src_mac']) + config_str += ' '*8 + 'src_mac: %s\n' % self.verify_mac(interface['src_mac']) if index % 2: config_str += '\n' # dual if barrier if not self.ignore_numa: @@ -432,7 +431,7 @@ Other network devices # input: list of different descriptions of interfaces: index, pci, name etc. # Binds to dpdk wanted interfaces, not bound to any driver. # output: list of maps of devices in dpdk_* format (self.m_devices.values()) - def _get_wanted_interfaces(self, input_interfaces): + def _get_wanted_interfaces(self, input_interfaces, get_macs = True): if type(input_interfaces) is not list: raise DpdkSetup('type of input interfaces should be list') if not len(input_interfaces): @@ -460,47 +459,52 @@ Other network devices dev['Interface_argv'] = interface wanted_interfaces.append(dev) - unbound = [] - dpdk_bound = [] - for interface in wanted_interfaces: - if 'Driver_str' not in interface: - unbound.append(interface['Slot']) - elif interface.get('Driver_str') in dpdk_nic_bind.dpdk_drivers: - dpdk_bound.append(interface['Slot']) - if unbound or dpdk_bound: - for pci, info in dpdk_nic_bind.get_info_from_trex(unbound + dpdk_bound).items(): - if pci not in self.m_devices: - raise DpdkSetup('Internal error: PCI %s is not found among devices' % pci) - self.m_devices[pci].update(info) + if get_macs: + unbound = [] + dpdk_bound = [] + for interface in wanted_interfaces: + if 'Driver_str' not in interface: + unbound.append(interface['Slot']) + elif interface.get('Driver_str') in dpdk_nic_bind.dpdk_drivers: + dpdk_bound.append(interface['Slot']) + if unbound or dpdk_bound: + for pci, info in dpdk_nic_bind.get_info_from_trex(unbound + dpdk_bound).items(): + if pci not in self.m_devices: + raise DpdkSetup('Internal error: PCI %s is not found among devices' % pci) + self.m_devices[pci].update(info) return wanted_interfaces def do_create(self): - # gather info about NICS from dpdk_nic_bind.py - if not self.m_devices: - self.run_dpdk_lspci() - wanted_interfaces = self._get_wanted_interfaces(map_driver.args.create_interfaces) ips = map_driver.args.ips def_gws = map_driver.args.def_gws dest_macs = map_driver.args.dest_macs - if ips: + if map_driver.args.force_macs: + ip_config = False + if ips: + raise DpdkSetup("If using --force-macs, should not specify ips") + if def_gws: + raise DpdkSetup("If using --force-macs, should not specify default gateways") + elif ips: ip_config = True if not def_gws: - print("If specifying ips, must specify also def-gws") - sys.exit(1) + raise DpdkSetup("If specifying ips, must specify also def-gws") if dest_macs: - print("If specifying ips, should not specify dest--macs") - sys.exit(1) - if len(ips) != len(def_gws) or len(ips) != len(wanted_interfaces): - print("Number of given IPs should equal number of given def-gws and number of interfaces") - sys.exit(1) + raise DpdkSetup("If specifying ips, should not specify dest--macs") + if len(ips) != len(def_gws) or len(ips) != len(map_driver.args.create_interfaces): + raise DpdkSetup("Number of given IPs should equal number of given def-gws and number of interfaces") else: if dest_macs: ip_config = False else: ip_config = True + # gather info about NICS from dpdk_nic_bind.py + if not self.m_devices: + self.run_dpdk_lspci() + wanted_interfaces = self._get_wanted_interfaces(map_driver.args.create_interfaces, get_macs = not ip_config) + for i, interface in enumerate(wanted_interfaces): dual_index = i + 1 - (i % 2) * 2 if ip_config: @@ -513,15 +517,17 @@ Other network devices else: interface['def_gw'] = ".".join(list(str(dual_index+1))*4) else: + dual_if = wanted_interfaces[dual_index] if 'MAC' not in interface: raise DpdkSetup('Could not determine MAC of interface: %s. Please verify with -t flag.' % interface['Interface_argv']) + if 'MAC' not in dual_if: + raise DpdkSetup('Could not determine MAC of interface: %s. Please verify with -t flag.' % dual_if['Interface_argv']) interface['src_mac'] = interface['MAC'] if isinstance(dest_macs, list) and len(dest_macs) > i: interface['dest_mac'] = dest_macs[i] - - if 'dest_mac' not in wanted_interfaces[dual_index]: - wanted_interfaces[dual_index]['dest_mac'] = interface['MAC'] # loopback - wanted_interfaces[dual_index]['loopback_dest'] = True + else: + interface['dest_mac'] = dual_if['MAC'] + interface['loopback_dest'] = True config = ConfigCreator(self._get_cpu_topology(), wanted_interfaces, include_lcores = map_driver.args.create_include, exclude_lcores = map_driver.args.create_exclude, only_first_thread = map_driver.args.no_ht, ignore_numa = map_driver.args.ignore_numa, @@ -533,8 +539,7 @@ Other network devices cpu_topology = self._get_cpu_topology() total_lcores = sum([len(lcores) for cores in cpu_topology.values() for lcores in cores.values()]) if total_lcores < 1: - print('Script could not determine number of cores of the system, exiting.') - sys.exit(1) + raise DpdkSetup('Script could not determine number of cores of the system, exiting.') elif total_lcores < 2: if dpdk_nic_bind.confirm("You only have 1 core and can't run TRex at all. Ignore and continue? (y/N): "): ignore_numa = True @@ -545,9 +550,18 @@ Other network devices ignore_numa = True else: sys.exit(1) + + if map_driver.args.force_macs: + ip_based = False + elif dpdk_nic_bind.confirm("By default, IP based configuration file will be created. Do you want to use MAC based config? (y/N)"): + ip_based = False + else: + ip_based = True + ip_addr_digit = 1 + if not self.m_devices: self.run_dpdk_lspci() - dpdk_nic_bind.show_table() + dpdk_nic_bind.show_table(get_macs = not ip_based) print('Please choose even number of interfaces from the list above, either by ID , PCI or Linux IF') print('Stateful will use order of interfaces: Client1 Server1 Client2 Server2 etc. for flows.') print('Stateless can be in any order.') @@ -576,12 +590,6 @@ Other network devices if not dpdk_nic_bind.confirm('Ignore and continue? (y/N): '): sys.exit(1) - if dpdk_nic_bind.confirm("By default, IP based configuration file will be created. Do you want to change to MAC based config? (y/N)"): - ip_based = False - else: - ip_based = True - ip_addr_digit = 1 - for i, interface in enumerate(wanted_interfaces): if not ip_based: if 'MAC' not in interface: @@ -598,7 +606,6 @@ Other network devices return if ip_based: - loopback_dest = True if ip_addr_digit % 2 == 0: dual_ip_digit = ip_addr_digit - 1 else: @@ -659,9 +666,12 @@ Other network devices def parse_parent_cfg (parent_cfg): parent_parser = argparse.ArgumentParser(add_help = False) + parent_parser.add_argument('-?', '-h', '--help', dest = 'help', action = 'store_true') parent_parser.add_argument('--cfg', default='') parent_parser.add_argument('--dump-interfaces', nargs='*', default=None) - args, unkown = parent_parser.parse_known_args(shlex.split(parent_cfg)) + args, _ = parent_parser.parse_known_args(shlex.split(parent_cfg)) + if args.help: + sys.exit(0) return (args.cfg, args.dump_interfaces) def process_options (): @@ -734,6 +744,10 @@ To see more detailed info on interfaces (table): help="""Destination MACs to be used in created yaml file. Without them, will assume loopback (0<->1, 2<->3 etc.)""", ) + parser.add_argument("--force-macs", default=False, action='store_true', + help="""Use MACs in created config file.""", + ) + parser.add_argument("--ips", nargs='*', default=[], action='store', help="""IP addresses to be used in created yaml file. Without them, will assume loopback (0<->1, 2<->3 etc.)""", ) @@ -783,6 +797,9 @@ To see more detailed info on interfaces (table): def main (): try: + if getpass.getuser() != 'root': + raise DpdkSetup('Please run this program as root/with sudo') + process_options () if map_driver.args.show: @@ -813,8 +830,5 @@ def main (): exit(-1) if __name__ == '__main__': - if getpass.getuser() != 'root': - print('Please run this program as root/with sudo') - exit(1) main() diff --git a/scripts/find_python.sh b/scripts/find_python.sh index 4a3452cb..12b173be 100755 --- a/scripts/find_python.sh +++ b/scripts/find_python.sh @@ -4,31 +4,21 @@ set +e # function finds python2 function find_python2 { - # two candidates - machine python and cisco linux python if [ -n "$PYTHON" ]; then # return; fi - - - MACHINE_PYTHON=python - CEL_PYTHON=/router/bin/python-2.7.4 - # try the machine python - PYTHON=$MACHINE_PYTHON - PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)" > /dev/null 2>&1 ` - if [ $? -eq 0 ]; then - return - fi - - # try the CEL python - PYTHON=$CEL_PYTHON - PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)" > /dev/null 2>&1 ` - if [ $? -eq 0 ]; then - return - fi + # try different Python paths + PYTHONS=( python /usr/bin/python /router/bin/python-2.7.4 ) + for PYTHON in ${PYTHONS[*]}; do + $PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)" > /dev/null 2>&1 + if [ $? -eq 0 ]; then + return + fi + done; - echo "*** $MACHINE_PYTHON - python version is too old, 2.7 at least is required" + echo "*** Python version is too old, 2.7 at least is required" exit -1 } @@ -40,19 +30,16 @@ function find_python3 { return; fi - MACHINE_PYTHON=python3 - ITAY_PYTHON=/auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3 - PYTHON=$MACHINE_PYTHON - PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34 and ver != 35)" > /dev/null 2>&1 ` - if [ $? -eq 0 ]; then - return - fi - PYTHON=$ITAY_PYTHON - PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34 and ver != 35)" > /dev/null 2>&1 ` - if [ $? -eq 0 ]; then - return - fi - echo "*** $MACHINE_PYTHON - python version does not match, 3.4 or 3.5 is required" + # try different Python3 paths + PYTHONS=( python3 /usr/bin/python3 /auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3 ) + for PYTHON in ${PYTHONS[*]}; do + $PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34 and ver != 35)" > /dev/null 2>&1 + if [ $? -eq 0 ]; then + return + fi + done; + + echo "*** Python3 version does not match, 3.4 or 3.5 is required" exit -1 } diff --git a/scripts/libzmq.so.3 b/scripts/libzmq.so.3 Binary files differindex 16980c27..a6aaff15 100644 --- a/scripts/libzmq.so.3 +++ b/scripts/libzmq.so.3 diff --git a/scripts/trex_show_threads.py b/scripts/trex_show_threads.py new file mode 100755 index 00000000..fabe6d68 --- /dev/null +++ b/scripts/trex_show_threads.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os + +def read_task_stats (task_path): + + # files + status = task_path + "/status" + stat = task_path + "/stat" + + stats_dict = {} + for line in open(status, 'r').readlines(): + name, value = line.split(':', 1) + stats_dict[name.strip().lower()] = value.strip() + + stat_data = open(stat, 'r').readline().split() + + stats_dict['last_sched_cpu'] = stat_data[-14] + + return stats_dict + + +def show_threads (pid): + process_dir = "/proc/{0}/task".format(pid) + task_paths = ["{0}/{1}".format(process_dir, task) for task in os.listdir(process_dir)] + + + header = [ 'Task Name', 'PID', 'Allowed CPU', 'Last Sched CPU', 'Asked Ctx Switch', 'Forced Ctx Switch'] + for x in header: + print('{:^20}'.format(x)), + print("") + + tasks = [] + for task_path in task_paths: + task = read_task_stats(task_path) + tasks.append(task) + + tasks = sorted(tasks, key = lambda x: int(x['cpus_allowed_list'])) + for task in tasks: + # name + print("{:<20}".format(task['name'])), + print("{:^20}".format(task['pid'])), + print("{:^20}".format(task['cpus_allowed_list'])), + print("{:^20}".format(task['last_sched_cpu'])), + print("{:^20}".format(task['voluntary_ctxt_switches'])), + print("{:^20}".format(task['nonvoluntary_ctxt_switches'])), + print("") + +def isnum (x): + try: + int(x) + return True + except ValueError: + return False + + +def find_trex_pid (): + procs = [x for x in os.listdir('/proc/') if isnum(x)] + for proc in procs: + cmd = open('/proc/{0}/{1}'.format(proc, 'cmdline')).readline() + if '_t-rex' in cmd: + return proc + + return None + +def main (): + trex_pid = find_trex_pid() + if trex_pid is None: + print("Unable to find Trex PID") + exit(1) + + print("\nTrex PID on {0}\n".format(trex_pid)) + show_threads(trex_pid) + + + +if __name__ == '__main__': + main() + |