Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions internal/extract/nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,27 @@ func NICIrqMappingsFromOutput(outputs map[string]script.ScriptOutput) [][]string
// NICSummaryFromOutput returns a summary of installed NICs.
func NICSummaryFromOutput(outputs map[string]script.ScriptOutput) string {
nics := ParseNicInfo(outputs[script.NicInfoScriptName].Stdout)
if len(nics) == 0 {
return "N/A"
}
modelCount := make(map[string]int)
for _, nic := range nics {
// don't include virtual functions or bridge devices in the summary as they are not physical NICs, and we want the summary to reflect physical hardware
if nic.IsVirtual || strings.Contains(nic.Name, "(virtual)") || nic.Driver == "bridge" {
continue
}
if strings.TrimSpace(nic.Model) == "" {
vendor := strings.TrimSpace(nic.Vendor)
if vendor == "" {
nic.Model = "Unknown Vendor and Model"
} else {
nic.Model = vendor + " Unknown Model"
}
}
modelCount[nic.Model]++
}
if len(modelCount) == 0 {
return "N/A"
}
var summary []string
for model, count := range modelCount {
if model == "" {
model = "Unknown NIC"
}
summary = append(summary, fmt.Sprintf("%dx %s", count, model))
}
return strings.Join(summary, ", ")
Expand Down
32 changes: 29 additions & 3 deletions internal/script/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,34 @@ rdmsr 0x2FFE
udevadm_out=$(udevadm info --query=all --path=/sys/class/net/"$ifc")
echo "Vendor ID: $(echo "$udevadm_out" | grep ID_VENDOR_ID= | cut -d'=' -f2)"
echo "Model ID: $(echo "$udevadm_out" | grep ID_MODEL_ID= | cut -d'=' -f2)"
echo "Vendor: $(echo "$udevadm_out" | grep ID_VENDOR_FROM_DATABASE= | cut -d'=' -f2)"
echo "Model: $(echo "$udevadm_out" | grep ID_MODEL_FROM_DATABASE= | cut -d'=' -f2)"
vendor=$(echo "$udevadm_out" | grep ID_VENDOR_FROM_DATABASE= | cut -d'=' -f2)
echo "Vendor: $vendor"
model=$(echo "$udevadm_out" | grep ID_MODEL_FROM_DATABASE= | cut -d'=' -f2)
# fall back to lspci if model is not available from udevadm, and trim vendor prefix if present (e.g. "Intel Ethernet Controller" -> "Ethernet Controller")
if [ -z "$model" ]; then
id_path=$(echo "$udevadm_out" | grep ID_PATH= | cut -d'=' -f2)
bdf=${id_path##*-}
# ID_PATH may include the domain (0000:49:00.0); lspci typically prints 49:00.0.
if [[ "$bdf" == *:*:* ]]; then
bdf=${bdf#*:}
fi
if [ -n "$bdf" ] && command -v lspci >/dev/null 2>&1; then
model=$(lspci -s "$bdf" -i pci.ids.gz | awk 'NR == 1 { pos = index($0, ": "); if (pos > 0) print substr($0, pos + 2); exit }')
if [ -n "$model" ] && [ -n "$vendor" ]; then
model=$(awk -v vendor="$vendor" -v model="$model" 'BEGIN {
v = tolower(vendor)
m = tolower(model)
out = model
if (v != "" && substr(m, 1, length(v)) == v) {
out = substr(model, length(v) + 1)
sub(/^[[:space:]]+/, "", out)
}
print out
}')
fi
fi
fi
echo "Model: $model"
echo "MTU: $(cat /sys/class/net/"$ifc"/mtu 2>/dev/null)"
echo "$ethtool_out"
echo "$ethtool_i_out"
Expand Down Expand Up @@ -883,7 +909,7 @@ rdmsr 0x2FFE
echo "----------------------------------------"
done
`,
Depends: []string{"ethtool"},
Depends: []string{"ethtool", "lspci", "pci.ids.gz"},
Superuser: true,
},
IRQBalanceScriptName: {
Expand Down
Loading