Files
rocm-systems/projects/rocprofiler-systems/tests/get_default_nic.sh
T
ajanicijamd 259ef6348b Fixed issues with nic-performance test (#1168)
- On some hosts the wget can finish too soon and PAPI doesn't catch even a single network event.
- On some hosts, there are multiple default NICs and the scripts didn't work in that case.
- The test script was writing the output of wget to /tmp directory, which causes a problem if another user tries to run the same test. Because the output file with the same name already exists in the same directory, but with a different owner, the test fails

---------

Co-authored-by: David Galiffi <David.Galiffi@amd.com>
2025-10-14 23:45:08 -04:00

20 lines
534 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
# This script gets the name of the default NIC and writes it to standard output.
# NOTE: if command "ip r" finds multiple default NICs, this script will output
# all of them.
nics=$(ip r | awk '/^default /{print $5}' | sort -u)
# nics="ens50f1 ens50f2 ens50f3 ens50f4" # For testing purposes only
# nics= # For testing purposes only
if [ -z "$nics" ]; then
echo "Error: no default route found" >&2
exit 1
fi
echo "$nics"