feat(exporter): flag PCIe/GPU/NIC devices with degraded link width as Warning

Applies a single universal check (negotiated LinkWidth < MaxLinkWidth) in
convertPCIeFromDevices, the shared conversion path all vendor parsers feed
into, so a narrower-than-supported link (bad seat, bent connector, wrong
riser) surfaces as a Warning status regardless of which parser produced the
reading — instead of the previous OtrdDiagnoseComponent.json-only check that
only covered the newer HGX dump layout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-08-13 18:15:08 +03:00
co-authored by Claude Sonnet 5
parent 93f0897b81
commit 0867123a91
+12
View File
@@ -998,6 +998,9 @@ func convertPCIeFromDevices(devices []models.HardwareDevice, collectedAt string)
float64(intFromDetailMap(d.Details, "power")), float64(intFromDetailMap(d.Details, "power")),
) )
status := normalizeStatus(d.Status, false) status := normalizeStatus(d.Status, false)
if status != "Critical" && isPCIeLinkWidthDegraded(d.LinkWidth, d.MaxLinkWidth) {
status = "Warning"
}
meta := buildStatusMeta(status, d.StatusCheckedAt, d.StatusChangedAt, d.StatusHistory, d.ErrorDescription, collectedAt) meta := buildStatusMeta(status, d.StatusCheckedAt, d.StatusChangedAt, d.StatusHistory, d.ErrorDescription, collectedAt)
slot := firstNonEmptyString(d.Slot, d.BDF) slot := firstNonEmptyString(d.Slot, d.BDF)
result = append(result, ReanimatorPCIe{ result = append(result, ReanimatorPCIe{
@@ -2649,6 +2652,15 @@ func normalizeStatus(status string, allowEmpty bool) string {
} }
} }
// isPCIeLinkWidthDegraded reports whether a device negotiated a narrower PCIe
// link than the slot/device supports (e.g. x8 in an x16 slot) — a signal of a
// bad seat, bent connector, or misconfigured riser. This runs once here, on
// the shared LinkWidth/MaxLinkWidth fields every vendor parser populates, so
// it applies uniformly regardless of which parser produced the reading.
func isPCIeLinkWidthDegraded(linkWidth, maxLinkWidth int) bool {
return linkWidth > 0 && maxLinkWidth > 0 && linkWidth < maxLinkWidth
}
var ( var (
ipv4Regex = regexp.MustCompile(`(?:^|[^0-9])((?:\d{1,3}\.){3}\d{1,3})(?:[^0-9]|$)`) ipv4Regex = regexp.MustCompile(`(?:^|[^0-9])((?:\d{1,3}\.){3}\d{1,3})(?:[^0-9]|$)`)
) )