Fixes #20. This onekeylog variant has no devicefrusdr.log at all: FRU/sensors come from raw ipmitool text output, PCIe/GPU presence has a dedicated structural snapshot, SEL lives at a different path, and BMC component failures are logged separately from SEL/IDL. - Fall back to component/fru.txt (same FRU block format as devicefrusdr.log) and component/sensor.txt / sdr.txt (ipmitool sensor list / sdr elist) when devicefrusdr.log is absent. - Parse log/bmc/diagnose/OtrdDiagnoseComponent.json's PCIe Device Info array for GPU/PCIe presence and link state, independent of SEL/IDL alarm history; flag devices running below their negotiated max link speed/width as degraded with a Warning event. - Fall back to log/sel.csv (same format as selelist.csv) when selelist.csv is absent. - Parse log/bmc/commer-comp/{commerslot,commerhmc,commerswvr,commerswcpld} logs (including rotated *.tar.gz.N parts) into failure events, filtering known-noisy lines. - Collapse SEL events duplicated across sources by (timestamp, event_type, description). - Surface a CollectionError when FRU/sensors are still empty after all fallbacks, instead of silently returning an empty inventory. - Fix ParseFRU: a later placeholder "Product Serial : 0" / "Product Part Number : NULL" line in the same FRU block (e.g. SCM_FRU) was overwriting an already-parsed real Board Serial/Part Number. Verified against dump_23DB01633_20260727-1359.tar.gz (HGX B200, KR9288-X3): fru 0→21, sensors 0→303, 8 GPUs present at Gen5 x16 in slots 100-107. Deferred (not covered by this change): BIOS-change-settings context and BIOS POST codes from the same layout — see bible-local/10-decisions.md ADL-048. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package inspur
|
|
|
|
import "testing"
|
|
|
|
func TestParseSensorList(t *testing.T) {
|
|
content := []byte(`============
|
|
Description:sensor list
|
|
Command: ipmitool sensor list
|
|
Response:
|
|
Inlet_Temp | 21.000 | degrees C | ok | na | na | na | na | 40.000 | na
|
|
GPU0_Temp | 29.000 | degrees C | ok | na | na | na | na | 86.000 | na
|
|
PSU0_Status | 0x0 | discrete | 0x0180| na | na | na | na | na | na
|
|
`)
|
|
|
|
readings := ParseSensorList(content)
|
|
if len(readings) != 3 {
|
|
t.Fatalf("expected 3 readings, got %d", len(readings))
|
|
}
|
|
if readings[0].Name != "Inlet_Temp" || readings[0].Value != 21.0 || readings[0].Unit != "degrees C" {
|
|
t.Fatalf("unexpected Inlet_Temp reading: %+v", readings[0])
|
|
}
|
|
if readings[1].Type != "temperature" {
|
|
t.Fatalf("expected temperature type, got %q", readings[1].Type)
|
|
}
|
|
}
|
|
|
|
func TestParseSDRElist(t *testing.T) {
|
|
content := []byte(`============
|
|
Description:sdr elist
|
|
Command: ipmitool sdr elist
|
|
Response:
|
|
Inlet_Temp | 00h | ok | 3.0 | 21 degrees C
|
|
GPU0_Temp | 2Ah | ok | 11.0 | 29 degrees C
|
|
Event Logging Disabled SEL_Status | 15h | ok | 7.0 | no reading
|
|
`)
|
|
|
|
readings := ParseSDRElist(content)
|
|
if len(readings) != 3 {
|
|
t.Fatalf("expected 3 readings, got %d", len(readings))
|
|
}
|
|
if readings[0].Name != "Inlet_Temp" || readings[0].Value != 21 || readings[0].Unit != "degrees C" {
|
|
t.Fatalf("unexpected Inlet_Temp reading: %+v", readings[0])
|
|
}
|
|
if readings[2].RawValue != "" {
|
|
t.Fatalf("expected no reading to leave RawValue empty, got %q", readings[2].RawValue)
|
|
}
|
|
}
|