Merge remote-tracking branch 'origin/main'

# Conflicts:
#	bible-local/10-decisions.md
#	internal/chart
#	internal/models/models.go
This commit is contained in:
Mikhail Chusavitin
2026-08-11 12:12:03 +03:00
17 changed files with 1709 additions and 2044 deletions
+98 -6
View File
@@ -1232,7 +1232,99 @@ later content-free duplicate cannot blank out an earlier real reading.
--- ---
## ADL-048 — Dell iDRAC10 TSR bundles ship inventory as a raw Redfish walk, not DCIM-XML ## ADL-048 — Inspur HGX `dump_<serial>_<timestamp>/` layout: ipmitool-output FRU/sensors, diagnose-json PCIe, commer-comp events
**Date:** 2026-07-29
**Context:** A field dump from an HGX B200 / KR9288-X3 (`dump_23DB01633_20260727-1359.tar.gz`)
uses yet another onekeylog variant that has no `devicefrusdr.log` at all (unlike ADL-047's
per-file D-Bus layout, which is missing only `component.log`). FRU and sensors come from raw
`ipmitool fru print` / `ipmitool sensor list` / `ipmitool sdr elist` output under
`component/{fru,sensor,sdr}.txt`. Without a fallback the parser returned `fru: 0, sensors: 0` on
an otherwise well-detected archive (`Detect()` still scored via `onekeylog_dreport.log`), silently
dropping inventory a diagnostic case (intermittent GPU PCIe dropout) depended on.
**Decision:**
- `component/fru.txt` uses the exact same `FRU Device Description :` block format as the FRU
section of `devicefrusdr.log`, so it's parsed with the existing `ParseFRU` unchanged.
- `component/sensor.txt` (`ipmitool sensor list`, has value+unit+status per line) is the primary
sensor fallback; `component/sdr.txt` (`ipmitool sdr elist`, no value on disabled sensors) is used
only if `sensor.txt` is absent. New parsers in `component_fallback.go`
(`ParseSensorList`, `ParseSDRElist`).
- `log/bmc/diagnose/OtrdDiagnoseComponent.json`'s `"Pcie Device Info"` array is a structural,
point-in-time PCIe snapshot (independent of SEL/IDL alarm history) — parsed by
`ParseOtrdDiagnosePCIe` in `diagnose.go` into `models.PCIeDevice` (using the existing
`Present *bool` field) and merged via the existing `MergePCIeDevices`. A device present but
running below its negotiated max link speed/width gets `Status = "Link Degraded"` and a
matching Warning event (`BuildPCIeLinkDegradationEvents`), independent of GPU-fault SEL/IDL
parsing in `gpu_status.go`.
- `log/sel.csv` is textually identical to `selelist.csv` (`ipmitool sel elist -c -Z` output with
the same 6-column CSV body) and is now a fallback source when `selelist.csv` is absent, reusing
`ParseSELListWithLocation` unchanged.
- `log/bmc/commer-comp/<commerslot|commerhmc|commerswvr|commerswcpld>/` component logs (plus
rotated `*.tar.gz.N` parts, decoded in-memory) share one line format
(`[timestamp][file, line][level] message`); `ParseCommerCompEvents` in `commercomp.go` emits an
event per line that looks like a real failure, after dropping a fixed noise list (`Invalid Comp
Data`, `Error in update redis`, `MutexTimeout = 0`).
- Fixed two long-standing `ParseFRU` bugs surfaced by this archive: `Board Serial`/`Board Part
Number` values were overwritten by a later, placeholder `Product Serial : 0` / `Product Part
Number : NULL` line within the same FRU block (e.g. `SCM_FRU`, which has no product-level FRU
fields). Placeholder values (`"0"`, `"NULL"`) no longer overwrite an already-set real value.
- Since duplicate SEL entries can now surface through more than one source file (`sel.csv` +
IDL/BMC logs) for the same moment, `Parse()` runs a final `dedupSELEvents` pass collapsing
`Source == "SEL"` events with identical `(timestamp, event_type, description)`. This is
deliberately narrower than IDL's own timestamp-inclusive dedup in `idl.go`, which must keep
distinct occurrences of a recurring alarm.
- When `Parse()` still ends up with `len(FRU) == 0 || len(Sensors) == 0` after all fallbacks, it
appends a `CollectionError{Section: "inventory"}` so the gap is visible in the API response
instead of silently returning an empty inventory.
**Consequences:**
- `stats.fru`/`stats.sensors` are non-zero on this dump class; GPU presence/link state is
available from a source independent of SEL/IDL alarm parsing.
- BIOS-change-settings context (`biosChangedSettings/Bios_change_settings*.json`) and BIOS POST
codes (`log/server/progress_log/host0/*`) from the same issue are not yet parsed — deferred,
no acceptance case depended on them yet.
- Any future ipmitool-text-output fallback (FRU/sensor/sdr) should extend
`component_fallback.go` rather than adding another one-off parser.
---
## ADL-049 — HGX tray/baseboard identity is a distinct entity from the vendor mechanical-carrier FRU
**Date:** 2026-07-29
**Context:** Issue #21 (Inspur/Kaytus HGX B200 dumps). `hw.BoardInfo`/vendor FRU (`component/fru.txt`
`Board Product : CA`, a `YZCA-*` part) identifies the mechanical carrier/tray shipped by Inspur —
it's bolted to the chassis and does not change when the actual NVIDIA HGX baseboard ("delta
board", SXM+NVSwitch) is swapped. Three dumps from the same server showed the CA carrier serial
constant across all three while the NVIDIA-assigned tray (`699-26612-*`) and baseboard
(`935-26287-*`) serials — read from `log/bmc/oem-commer-log/HGX_HWInfo_FWVersion.log` — stayed
identical between dumps A/B (~4 weeks apart) and both changed together in dump C, i.e. only
`HGX_HWInfo_FWVersion.log` actually reflects a baseboard swap.
**Decision:**
- Added `models.HGXIdentity` (`Tray`, `Baseboard`, each a `Model`/`PartNumber`/`SerialNumber`
triple) as `HardwareConfig.HGX`, populated by `parseHGXIdentity` in
`internal/parser/vendors/inspur/hgx_hwinfo.go` from the same `HGX_HWInfo_FWVersion.log` file
already used for GPU assembly/firmware enrichment.
- The log is a sequence of `# curl ... <redfish-path>` comment lines each followed by that
request's JSON response; `splitCurlBlocks` chunks on the comment lines so fields are attributed
to the path that produced them (classified by `tray`/`baseboard` substring, order-independent
field regexes — unlike the existing fixed-order `reHGXGPUBlock` regex for GPU assembly). Paths
containing `gpu_sxm` or `/processors/` are explicitly excluded so a per-GPU triple can never be
misattributed to the tray/baseboard entity.
- `hgxValue()` normalizes Redfish's `NA`/`N/A` placeholder (seen when GPUs are unpowered but the
baseboard itself still responds) to empty string, applied to both the new identity parser and
the existing per-GPU assembly parser, so `"NA"` never leaks into a serial/model/part field.
- Deliberately left `hw.BoardInfo`/vendor FRU parsing (`fru.go`) unchanged — it is not wrong, just
a different entity (mechanical carrier). Consumers that need "did the actual GPU board change"
must compare `HardwareConfig.HGX`, not `BoardInfo`.
**Consequences:**
- Dump-to-dump baseboard/tray swap detection (issue #21's P2) is now possible by comparing two
`HardwareConfig.HGX` values; not yet wired into any diff/comparison UI.
- GPU-status "baseboard responds, GPU not readable" surfacing (P1) is a natural follow-on now that
GPU fields normalize through the same `NA`-aware path, but no dedicated event/diagnostic was
added yet — deferred, no acceptance case depended on it.
---
## ADL-050 — Dell iDRAC10 TSR bundles ship inventory as a raw Redfish walk, not DCIM-XML
**Date:** 2026-08-11 **Date:** 2026-08-11
**Context:** A TSR from a PowerEdge R7715 (`TSR20260721231613_1TVFYL4.zip`, iDRAC10-generation **Context:** A TSR from a PowerEdge R7715 (`TSR20260721231613_1TVFYL4.zip`, iDRAC10-generation
@@ -1273,10 +1365,10 @@ of raw Redfish walk is picked up automatically without a dedicated parser.
--- ---
## ADL-049 — Reanimator export/re-import round trip silently dropped Memory and PSUs ## ADL-051 — Reanimator export/re-import round trip silently dropped Memory and PSUs
**Date:** 2026-08-11 **Date:** 2026-08-11
**Context:** After ADL-048 fixed Dell iDRAC10 inventory parsing, the same PowerEdge R7715 archive **Context:** After ADL-050 fixed Dell iDRAC10 inventory parsing, the same PowerEdge R7715 archive
still showed no Memory or Power Supplies sections in the `/chart/current` web view, even though still showed no Memory or Power Supplies sections in the `/chart/current` web view, even though
`internal/exporter.ConvertToReanimator` produced both correctly from a fresh TSR upload (verified via `internal/exporter.ConvertToReanimator` produced both correctly from a fresh TSR upload (verified via
direct API calls against the running server). The web view *did* break identically after re-uploading direct API calls against the running server). The web view *did* break identically after re-uploading
@@ -1313,7 +1405,7 @@ given the field it needs from a re-imported export.
--- ---
## ADL-050 — Added `hardware.licenses[]` collection/export (contract v2.12), Dell iDRAC10 first ## ADL-052 — Added `hardware.licenses[]` collection/export (contract v2.12), Dell iDRAC10 first
**Date:** 2026-08-11 **Date:** 2026-08-11
**Context:** Reanimator's hardware ingest contract added an optional `hardware.licenses[]` section in **Context:** Reanimator's hardware ingest contract added an optional `hardware.licenses[]` section in
@@ -1321,7 +1413,7 @@ v2.12 (2026-08-11) for software/firmware licenses and feature-on-demand activati
licenses, vGPU, CPU FoD, RAID feature unlocks, etc). LOGPile's local copy of licenses, vGPU, CPU FoD, RAID feature unlocks, etc). LOGPile's local copy of
`bible-local/docs/hardware-ingest-contract.md` was still v2.11 and was refreshed from `bible-local/docs/hardware-ingest-contract.md` was still v2.11 and was refreshed from
`reanimator/core/bible-local/docs/hardware-ingest-contract.md`. Scoped the first implementation to the `reanimator/core/bible-local/docs/hardware-ingest-contract.md`. Scoped the first implementation to the
Dell iDRAC10 Redfish-walk path (`vendors/dell` + `vendors/redfishwalk`, see ADL-048/049), since that's Dell iDRAC10 Redfish-walk path (`vendors/dell` + `vendors/redfishwalk`, see ADL-050/051), since that's
the only resolver currently producing a full captured Redfish tree with a `LicenseService` collection the only resolver currently producing a full captured Redfish tree with a `LicenseService` collection
in it — other vendor parsers have no comparable source for this data yet. in it — other vendor parsers have no comparable source for this data yet.
**Decision:** **Decision:**
@@ -1341,7 +1433,7 @@ in it — other vendor parsers have no comparable source for this data yet.
`license_key`, falling back to `component_ref|name`) added, wired into `ConvertToReanimator` `license_key`, falling back to `component_ref|name`) added, wired into `ConvertToReanimator`
directly from `hw.Licenses` — licenses don't go through the canonical-devices merge/dedup pipeline directly from `hw.Licenses` — licenses don't go through the canonical-devices merge/dedup pipeline
used for PCIe/GPU/NIC, since they carry no physical identity to merge on. `ReanimatorLicense.Present` used for PCIe/GPU/NIC, since they carry no physical identity to merge on. `ReanimatorLicense.Present`
is set on every emitted record (learned from ADL-049 — declaring the field isn't enough, it must is set on every emitted record (learned from ADL-051 — declaring the field isn't enough, it must
actually be populated for the reanimator round-trip to survive). actually be populated for the reanimator round-trip to survive).
- `internal/chart/viewer/render.go`: added a `licenses` section (between `power_supplies` and - `internal/chart/viewer/render.go`: added a `licenses` section (between `power_supplies` and
`sensors`) so licenses show up in the `/chart/current` web view like every other hardware category. `sensors`) so licenses show up in the `/chart/current` web view like every other hardware category.
+20
View File
@@ -107,6 +107,26 @@ type HardwareConfig struct {
NetworkAdapters []NetworkAdapter `json:"network_adapters,omitempty"` NetworkAdapters []NetworkAdapter `json:"network_adapters,omitempty"`
PowerSupply []PSU `json:"power_supplies,omitempty"` PowerSupply []PSU `json:"power_supplies,omitempty"`
Licenses []License `json:"licenses,omitempty"` Licenses []License `json:"licenses,omitempty"`
HGX *HGXIdentity `json:"hgx,omitempty"`
}
// HGXAssemblyIdentity is the Model/PartNumber/SerialNumber triple for one
// NVIDIA HGX Redfish assembly (tray or baseboard), read from HWInfo/FWVersion.
type HGXAssemblyIdentity struct {
Model string `json:"model,omitempty"`
PartNumber string `json:"part_number,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
}
// HGXIdentity holds the NVIDIA HGX hardware identity as reported by the BMC's
// HGX_HWInfo_FWVersion.log Redfish snapshot. This is distinct from BoardInfo:
// BoardInfo/vendor FRU describe the mechanical carrier/tray shipped by the
// server OEM (e.g. Inspur's YZCA-* part), which does not change when the
// NVIDIA HGX baseboard ("delta board") itself is replaced. Tray/Baseboard
// here are the actual NVIDIA-assigned identities that do change on a swap.
type HGXIdentity struct {
Tray HGXAssemblyIdentity `json:"tray,omitempty"`
Baseboard HGXAssemblyIdentity `json:"baseboard,omitempty"`
} }
const ( const (
+169
View File
@@ -0,0 +1,169 @@
// Parses log/bmc/commer-comp/*, per-component BMC transcripts (slot presence,
// HGX management controller, switch VR/power, switch CPLD). Each rotated log
// (component.log plus component.tar.gz.0..9) uses the same
// "[timestamp][file, line][level] message" line format.
package inspur
import (
"archive/tar"
"bufio"
"bytes"
"compress/gzip"
"fmt"
"io"
"regexp"
"strings"
"time"
"git.mchus.pro/mchus/logpile/internal/models"
"git.mchus.pro/mchus/logpile/internal/parser"
)
var commerCompComponents = []string{"commerslot", "commerhmc", "commerswvr", "commerswcpld"}
var commerCompLineRegex = regexp.MustCompile(`^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\]\[[^\]]*\]\[(\w+)\]\s*(.+)$`)
var commerCompNoisePatterns = []*regexp.Regexp{
regexp.MustCompile(`(?i)invalid comp data`),
regexp.MustCompile(`(?i)error in update redis`),
regexp.MustCompile(`(?i)mutextimeout\s*=\s*0`),
}
var commerCompFailureRegex = regexp.MustCompile(`(?i)\b(fail|failed|failure|error)\b`)
// ParseCommerCompEvents extracts BMC component failure events from
// log/bmc/commer-comp/<component>/ logs, including rotated *.tar.gz.N parts.
func ParseCommerCompEvents(files []parser.ExtractedFile, location *time.Location) []models.Event {
var events []models.Event
for _, f := range files {
path := strings.ToLower(f.Path)
if !strings.Contains(path, "/commer-comp/") {
continue
}
component := commerCompComponentFromPath(path)
if component == "" {
continue
}
if strings.Contains(path, ".tar.gz") {
for _, part := range decodeNestedTarGz(f.Content) {
events = append(events, parseCommerCompLog(part, component, location)...)
}
continue
}
if !strings.HasSuffix(path, ".log") {
continue
}
events = append(events, parseCommerCompLog(f.Content, component, location)...)
}
return events
}
func commerCompComponentFromPath(path string) string {
for _, c := range commerCompComponents {
if strings.Contains(path, "/"+c+"/") {
return c
}
}
return ""
}
// decodeNestedTarGz unpacks a rotated log part (a full tar.gz archive stored
// as e.g. commerhmc.tar.gz.0) and returns the contents of every regular file
// inside it.
func decodeNestedTarGz(content []byte) [][]byte {
gz, err := gzip.NewReader(bytes.NewReader(content))
if err != nil {
return nil
}
defer gz.Close()
tr := tar.NewReader(gz)
var out [][]byte
for {
hdr, err := tr.Next()
if err == io.EOF {
break
}
if err != nil {
break
}
if hdr.Typeflag != tar.TypeReg {
continue
}
buf, err := io.ReadAll(tr)
if err != nil {
continue
}
out = append(out, buf)
}
return out
}
func parseCommerCompLog(content []byte, component string, location *time.Location) []models.Event {
var events []models.Event
scanner := bufio.NewScanner(bytes.NewReader(content))
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
for scanner.Scan() {
line := scanner.Text()
m := commerCompLineRegex.FindStringSubmatch(line)
if m == nil {
continue
}
msg := strings.TrimSpace(m[3])
if isCommerCompNoise(msg) || !commerCompFailureRegex.MatchString(msg) {
continue
}
ts, err := time.ParseInLocation("2006-01-02 15:04:05", m[1], location)
if err != nil {
continue
}
events = append(events, models.Event{
ID: fmt.Sprintf("commer_comp_%s_%d_%s", component, ts.Unix(), commerCompIDSuffix(msg)),
Timestamp: ts,
Source: fmt.Sprintf("BMC/%s", component),
SensorType: "bmc_component",
EventType: m[2],
Severity: commerCompSeverity(m[2]),
Description: msg,
RawData: line,
})
}
return events
}
func isCommerCompNoise(msg string) bool {
for _, re := range commerCompNoisePatterns {
if re.MatchString(msg) {
return true
}
}
return false
}
var commerCompNonAlnumRegex = regexp.MustCompile(`[^a-zA-Z0-9]+`)
// commerCompIDSuffix derives a short, stable suffix from the message so that
// two different failures logged in the same second get distinct event IDs.
func commerCompIDSuffix(msg string) string {
s := commerCompNonAlnumRegex.ReplaceAllString(strings.ToLower(msg), "_")
s = strings.Trim(s, "_")
if len(s) > 40 {
s = s[:40]
}
return s
}
func commerCompSeverity(level string) models.Severity {
switch strings.ToLower(level) {
case "critial", "critical", "error":
return models.SeverityCritical
case "warning", "warn":
return models.SeverityWarning
default:
return models.SeverityInfo
}
}
+36
View File
@@ -0,0 +1,36 @@
package inspur
import (
"testing"
"time"
"git.mchus.pro/mchus/logpile/internal/parser"
)
func TestParseCommerCompEvents(t *testing.T) {
content := []byte(`[2026-07-08 16:46:19][commer_comp_anal.c, 635][Critial] [COMP]Invalid Comp Data, Continue... ParamList: Index-3, Valid-0x1, MediaType-0(1-PCIE,2-I2C)
[2026-07-27 04:52:55][commer_comp_slot.c, 319][Critial] Data Update fail for dev serial-6!
[2026-07-27 04:52:55][commer_comp_slot.c, 319][Critial] Data Update fail for dev serial-7!
[2026-07-27 05:00:00][commer_comp_slot.c, 100][Info] Error in update redis, retry
`)
files := []parser.ExtractedFile{
{Path: "log/bmc/commer-comp/commerslot/commerslot.log", Content: content},
}
events := ParseCommerCompEvents(files, time.UTC)
if len(events) != 2 {
t.Fatalf("expected 2 events (noise filtered), got %d: %+v", len(events), events)
}
for _, e := range events {
if e.Source != "BMC/commerslot" {
t.Fatalf("unexpected source %q", e.Source)
}
}
if events[0].Timestamp.Format("2006-01-02 15:04:05") != "2026-07-27 04:52:55" {
t.Fatalf("unexpected timestamp: %v", events[0].Timestamp)
}
if events[0].ID == events[1].ID {
t.Fatalf("expected distinct event IDs for serial-6/serial-7, got same: %q", events[0].ID)
}
}
+104
View File
@@ -0,0 +1,104 @@
// Fallback inventory parsing for the per-file dump_<serial>_<timestamp>/ onekeylog
// layout, which has no combined devicefrusdr.log. Instead FRU and sensors live in
// separate ipmitool-output text files under component/.
package inspur
import (
"bufio"
"strconv"
"strings"
"git.mchus.pro/mchus/logpile/internal/models"
)
// ParseSensorList parses component/sensor.txt ("ipmitool sensor list" output).
// Line format: Name | Value | Unit | Status | lnr | lcr | lnc | unc | ucr | unr
func ParseSensorList(content []byte) []models.SensorReading {
var readings []models.SensorReading
scanner := bufio.NewScanner(strings.NewReader(string(content)))
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" || !strings.Contains(line, "|") {
continue
}
fields := strings.Split(line, "|")
if len(fields) < 4 {
continue
}
name := strings.TrimSpace(fields[0])
valueStr := strings.TrimSpace(fields[1])
unit := strings.TrimSpace(fields[2])
status := strings.TrimSpace(fields[3])
if name == "" {
continue
}
reading := models.SensorReading{
Name: name,
Status: status,
Unit: unit,
Type: determineSensorType(name),
}
if valueStr != "" && valueStr != "na" {
if v, err := strconv.ParseFloat(valueStr, 64); err == nil {
reading.Value = v
reading.RawValue = valueStr + " " + unit
} else {
reading.RawValue = valueStr
}
}
readings = append(readings, reading)
}
return readings
}
// ParseSDRElist parses component/sdr.txt ("ipmitool sdr elist" output), used as a
// fallback when component/sensor.txt is unavailable.
// Line format: Name | ID | Status | Entity | Reading (e.g. "21 degrees C" or "no reading")
func ParseSDRElist(content []byte) []models.SensorReading {
var readings []models.SensorReading
scanner := bufio.NewScanner(strings.NewReader(string(content)))
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" || !strings.Contains(line, "|") {
continue
}
fields := strings.Split(line, "|")
if len(fields) < 3 {
continue
}
name := strings.TrimSpace(fields[0])
status := strings.TrimSpace(fields[2])
if name == "" {
continue
}
reading := models.SensorReading{
Name: name,
Status: status,
Type: determineSensorType(name),
}
if len(fields) >= 5 {
readingStr := strings.TrimSpace(fields[4])
if readingStr != "" && readingStr != "no reading" {
reading.RawValue = readingStr
if m := valueRegex.FindStringSubmatch(readingStr); m != nil {
if v, err := strconv.ParseFloat(m[1], 64); err == nil {
reading.Value = v
reading.Unit = strings.TrimSpace(m[2])
}
}
}
}
readings = append(readings, reading)
}
return readings
}
@@ -0,0 +1,47 @@
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)
}
}
+121
View File
@@ -0,0 +1,121 @@
// Parses log/bmc/diagnose/OtrdDiagnoseComponent.json, an HGX BMC structural
// snapshot of PCIe topology (present GPUs/NICs/NVMe, negotiated link state).
// This is a direct point-in-time source for GPU presence and PCIe link
// degradation, independent of SEL/IDL alarm history.
package inspur
import (
"encoding/json"
"fmt"
"strings"
"git.mchus.pro/mchus/logpile/internal/models"
"git.mchus.pro/mchus/logpile/internal/parser/vendors/pciids"
)
// otrdDiagnosePCIeEntry mirrors the relevant fields of "Pcie Device Info"
// entries in OtrdDiagnoseComponent.json.
type otrdDiagnosePCIeEntry struct {
LocString string `json:"LocString"`
PcieSlot int `json:"PcieSlot"`
PresentStatus int `json:"PresentStatus"`
VendorId int `json:"VendorId"`
DeviceId int `json:"DeviceId"`
BusNumber int `json:"BusNumber"`
DeviceNumber int `json:"DeviceNumber"`
FunctionNumber int `json:"FunctionNumber"`
CurrentLinkSpeed int `json:"CurrentLinkSpeed"`
MaxLinkSpeed int `json:"MaxLinkSpeed"`
NegotiatedLinkWidth int `json:"NegotiatedLinkWidth"`
MaxLinkWidth int `json:"MaxLinkWidth"`
SerialNumber *string `json:"SerialNumber"`
PartNumber *string `json:"PartNumber"`
}
type otrdDiagnoseComponent struct {
PcieDeviceInfo []otrdDiagnosePCIeEntry `json:"Pcie Device Info"`
}
// ParseOtrdDiagnosePCIe parses the "Pcie Device Info" array from
// OtrdDiagnoseComponent.json into PCIe device inventory entries.
func ParseOtrdDiagnosePCIe(content []byte) []models.PCIeDevice {
var doc otrdDiagnoseComponent
if err := json.Unmarshal(content, &doc); err != nil {
return nil
}
devices := make([]models.PCIeDevice, 0, len(doc.PcieDeviceInfo))
for _, e := range doc.PcieDeviceInfo {
present := e.PresentStatus == 1
_, deviceName := pciids.DeviceInfo(e.VendorId, e.DeviceId)
deviceClass := normalizeModelLabel(deviceName)
if strings.Contains(strings.ToUpper(deviceName), "NVIDIA") {
deviceClass = "GPU (" + deviceName + ")"
}
serial := ""
if e.SerialNumber != nil {
serial = strings.TrimSpace(*e.SerialNumber)
}
partNum := ""
if e.PartNumber != nil {
partNum = strings.TrimSpace(*e.PartNumber)
}
status := ""
if present && isLinkDegraded(e) {
status = "Link Degraded"
}
devices = append(devices, models.PCIeDevice{
Slot: e.LocString,
VendorID: e.VendorId,
DeviceID: e.DeviceId,
BDF: formatBDF(e.BusNumber, e.DeviceNumber, e.FunctionNumber),
DeviceClass: deviceClass,
Manufacturer: normalizeModelLabel(pciids.VendorName(e.VendorId)),
LinkWidth: e.NegotiatedLinkWidth,
LinkSpeed: fmt.Sprintf("GEN%d", e.CurrentLinkSpeed),
MaxLinkWidth: e.MaxLinkWidth,
MaxLinkSpeed: fmt.Sprintf("GEN%d", e.MaxLinkSpeed),
PartNumber: partNum,
SerialNumber: serial,
Present: &present,
Status: status,
})
}
return devices
}
func isLinkDegraded(e otrdDiagnosePCIeEntry) bool {
if e.MaxLinkSpeed > 0 && e.CurrentLinkSpeed < e.MaxLinkSpeed {
return true
}
if e.MaxLinkWidth > 0 && e.NegotiatedLinkWidth < e.MaxLinkWidth {
return true
}
return false
}
// BuildPCIeLinkDegradationEvents emits a Warning event for every PCIe device
// present in OtrdDiagnoseComponent.json but running below its negotiated max
// link speed/width (e.g. a GPU baseboard degrading from Gen5 x16 to a lower
// state), so the log viewer surfaces the same signal the IDL alarms would.
func BuildPCIeLinkDegradationEvents(devices []models.PCIeDevice) []models.Event {
var events []models.Event
for _, d := range devices {
if d.Present == nil || !*d.Present || d.Status != "Link Degraded" {
continue
}
events = append(events, models.Event{
ID: fmt.Sprintf("pcie_link_degraded_%s", strings.TrimPrefix(d.Slot, "#")),
Source: "PCIe Diagnose",
SensorType: "pcie_link",
EventType: "Link Degraded",
Severity: models.SeverityWarning,
Description: fmt.Sprintf("%s: link degraded to %s x%d (max %s x%d)", d.Slot, d.LinkSpeed, d.LinkWidth, d.MaxLinkSpeed, d.MaxLinkWidth),
})
}
return events
}
+70
View File
@@ -0,0 +1,70 @@
package inspur
import "testing"
const diagnoseJSONFixture = `{
"Pcie Device Info": [
{
"LocString": "#GPU0",
"PcieSlot": 100,
"PresentStatus": 1,
"VendorId": 4318,
"DeviceId": 10497,
"BusNumber": 23,
"DeviceNumber": 0,
"FunctionNumber": 0,
"CurrentLinkSpeed": 5,
"MaxLinkSpeed": 5,
"NegotiatedLinkWidth": 16,
"MaxLinkWidth": 16
},
{
"LocString": "#GPU6",
"PcieSlot": 106,
"PresentStatus": 1,
"VendorId": 4318,
"DeviceId": 10497,
"BusNumber": 220,
"DeviceNumber": 0,
"FunctionNumber": 0,
"CurrentLinkSpeed": 2,
"MaxLinkSpeed": 5,
"NegotiatedLinkWidth": 8,
"MaxLinkWidth": 16
}
]
}`
func TestParseOtrdDiagnosePCIe(t *testing.T) {
devices := ParseOtrdDiagnosePCIe([]byte(diagnoseJSONFixture))
if len(devices) != 2 {
t.Fatalf("expected 2 devices, got %d", len(devices))
}
gpu0 := devices[0]
if gpu0.Slot != "#GPU0" || gpu0.Present == nil || !*gpu0.Present {
t.Fatalf("expected GPU0 present, got %+v", gpu0)
}
if gpu0.Status == "Link Degraded" {
t.Fatalf("GPU0 should not be flagged as degraded: %+v", gpu0)
}
if gpu0.LinkSpeed != "GEN5" || gpu0.MaxLinkSpeed != "GEN5" || gpu0.LinkWidth != 16 {
t.Fatalf("unexpected GPU0 link info: %+v", gpu0)
}
gpu6 := devices[1]
if gpu6.Status != "Link Degraded" {
t.Fatalf("expected GPU6 to be flagged as degraded, got %+v", gpu6)
}
}
func TestBuildPCIeLinkDegradationEvents(t *testing.T) {
devices := ParseOtrdDiagnosePCIe([]byte(diagnoseJSONFixture))
events := BuildPCIeLinkDegradationEvents(devices)
if len(events) != 1 {
t.Fatalf("expected 1 degradation event, got %d", len(events))
}
if events[0].Severity != "warning" {
t.Fatalf("expected warning severity, got %q", events[0].Severity)
}
}
+9 -2
View File
@@ -72,9 +72,16 @@ func ParseFRU(content []byte) []models.FRUInfo {
current.ProductName = fieldValue current.ProductName = fieldValue
} }
case "Board Serial", "Product Serial": case "Board Serial", "Product Serial":
current.SerialNumber = fieldValue // Modules with no product-level FRU (e.g. SCM_FRU) report
// "Product Serial : 0" after a real "Board Serial" value;
// don't let the placeholder overwrite the real serial.
if fieldValue != "0" && fieldValue != "NULL" {
current.SerialNumber = fieldValue
}
case "Board Part Number", "Product Part Number": case "Board Part Number", "Product Part Number":
if fieldValue != "0" { // See "Board Serial" above: placeholder "NULL"/"0" product-level
// fields must not overwrite a real board-level part number.
if fieldValue != "0" && fieldValue != "NULL" {
current.PartNumber = fieldValue current.PartNumber = fieldValue
} }
case "Product Version": case "Product Version":
+101 -3
View File
@@ -48,8 +48,106 @@ var (
reIDLine = regexp.MustCompile(`"Id":\s*"([^"]+)"`) reIDLine = regexp.MustCompile(`"Id":\s*"([^"]+)"`)
reVersion = regexp.MustCompile(`"Version":\s*"([^"]*)"`) reVersion = regexp.MustCompile(`"Version":\s*"([^"]*)"`)
reSlotGPU = regexp.MustCompile(`(?i)gpu\s*#?\s*(\d+)`) reSlotGPU = regexp.MustCompile(`(?i)gpu\s*#?\s*(\d+)`)
reCurlLine = regexp.MustCompile(`(?m)^#.*curl.*$`)
reRedfishPath = regexp.MustCompile(`(/redfish/v1/\S+)`)
reFieldModel = regexp.MustCompile(`"Model"\s*:\s*"([^"]*)"`)
reFieldPart = regexp.MustCompile(`"PartNumber"\s*:\s*"([^"]*)"`)
reFieldSerial = regexp.MustCompile(`"SerialNumber"\s*:\s*"([^"]*)"`)
) )
// hgxValue normalizes a raw HWInfo field value, treating Redfish's "not
// applicable" placeholders (e.g. an unpowered/absent GPU) as empty so they
// never overwrite or masquerade as real identity data.
func hgxValue(raw string) string {
v := strings.TrimSpace(raw)
switch strings.ToUpper(v) {
case "", "NA", "N/A":
return ""
default:
return v
}
}
// splitCurlBlocks splits a HGX_HWInfo_FWVersion.log-style dump (a sequence of
// "# curl ... <url>" comment lines each followed by that request's JSON
// response) into per-request chunks, so fields can be attributed to the
// Redfish path that produced them.
func splitCurlBlocks(content []byte) []string {
text := string(content)
locs := reCurlLine.FindAllStringIndex(text, -1)
if len(locs) == 0 {
return []string{text}
}
blocks := make([]string, 0, len(locs))
for i, loc := range locs {
end := len(text)
if i+1 < len(locs) {
end = locs[i+1][0]
}
blocks = append(blocks, text[loc[0]:end])
}
return blocks
}
// parseHGXIdentity extracts the NVIDIA HGX tray and baseboard hardware
// identity (Model/PartNumber/SerialNumber) from a HGX_HWInfo_FWVersion.log
// dump. Unlike the vendor mechanical-carrier FRU, these serials change when
// the actual HGX tray/baseboard ("delta board") is swapped.
func parseHGXIdentity(content []byte) *models.HGXIdentity {
if len(content) == 0 {
return nil
}
var identity models.HGXIdentity
found := false
for _, block := range splitCurlBlocks(content) {
path := reRedfishPath.FindString(block)
if path == "" {
continue
}
lowerPath := strings.ToLower(path)
// GPU-specific and GPU-scoped paths are handled by
// parseHGXGPUAssembly/parseHGXGPUFirmware; skip them here so a
// per-GPU Model/PartNumber/SerialNumber triple never gets
// misattributed to the tray or baseboard.
if strings.Contains(lowerPath, "gpu_sxm") || strings.Contains(lowerPath, "/processors/") {
continue
}
info := models.HGXAssemblyIdentity{}
if m := reFieldModel.FindStringSubmatch(block); m != nil {
info.Model = hgxValue(m[1])
}
if m := reFieldPart.FindStringSubmatch(block); m != nil {
info.PartNumber = hgxValue(m[1])
}
if m := reFieldSerial.FindStringSubmatch(block); m != nil {
info.SerialNumber = hgxValue(m[1])
}
if info.Model == "" && info.PartNumber == "" && info.SerialNumber == "" {
continue
}
switch {
case strings.Contains(lowerPath, "tray"):
identity.Tray = info
found = true
case strings.Contains(lowerPath, "baseboard"):
identity.Baseboard = info
found = true
}
}
if !found {
return nil
}
return &identity
}
func enrichGPUsFromHGXHWInfo(content []byte, hw *models.HardwareConfig) { func enrichGPUsFromHGXHWInfo(content []byte, hw *models.HardwareConfig) {
if hw == nil || len(hw.GPUs) == 0 || len(content) == 0 { if hw == nil || len(hw.GPUs) == 0 || len(content) == 0 {
return return
@@ -157,9 +255,9 @@ func parseHGXGPUAssembly(content []byte) map[int]hgxGPUAssemblyInfo {
} }
result[sxmIdx] = hgxGPUAssemblyInfo{ result[sxmIdx] = hgxGPUAssemblyInfo{
Model: strings.TrimSpace(string(m[2])), Model: hgxValue(string(m[2])),
Part: strings.TrimSpace(string(m[3])), Part: hgxValue(string(m[3])),
Serial: strings.TrimSpace(string(m[4])), Serial: hgxValue(string(m[4])),
} }
} }
return result return result
+78
View File
@@ -0,0 +1,78 @@
package inspur
import (
"testing"
)
func TestParseHGXIdentity_ExtractsTrayAndBaseboard(t *testing.T) {
content := []byte(`
# curl -X GET http://127.0.0.1/redfish/v1/Chassis/HGX_Tray_0/Assembly
{"Name":"HGX Tray Assembly","Model":"P6612-A04","PartNumber":"699-26612-0000-P00","SerialNumber":"TRAYSN1"}
# curl -X GET http://127.0.0.1/redfish/v1/Systems/HGX_Baseboard_0
{"Model":"NVIDIA HGX B200 8 GPU","PartNumber":"935-26287-00A0-000","SerialNumber":"BBSN1"}
# curl -X GET http://127.0.0.1/redfish/v1/Systems/HGX_Baseboard_0/Processors/GPU_SXM_1
{"Model":"B200 180GB HBM3e","PartNumber":"692-2G525-0220-501","SerialNumber":"GPUSN1"}
`)
identity := parseHGXIdentity(content)
if identity == nil {
t.Fatal("expected non-nil identity")
}
if identity.Tray.Model != "P6612-A04" || identity.Tray.PartNumber != "699-26612-0000-P00" || identity.Tray.SerialNumber != "TRAYSN1" {
t.Fatalf("unexpected tray identity: %+v", identity.Tray)
}
if identity.Baseboard.Model != "NVIDIA HGX B200 8 GPU" || identity.Baseboard.PartNumber != "935-26287-00A0-000" || identity.Baseboard.SerialNumber != "BBSN1" {
t.Fatalf("unexpected baseboard identity: %+v", identity.Baseboard)
}
// The per-GPU Processors path must never leak into baseboard/tray identity.
if identity.Baseboard.SerialNumber == "GPUSN1" || identity.Tray.SerialNumber == "GPUSN1" {
t.Fatalf("GPU serial leaked into baseboard/tray identity: %+v", identity)
}
}
func TestParseHGXIdentity_DetectsBaseboardSwapAcrossDumps(t *testing.T) {
dumpA := []byte(`
# curl -X GET http://127.0.0.1/redfish/v1/Chassis/HGX_Tray_0/Assembly
{"Name":"HGX Tray Assembly","Model":"P6612-A04","PartNumber":"699-26612-0000-P00","SerialNumber":"TRAY-1"}
# curl -X GET http://127.0.0.1/redfish/v1/Systems/HGX_Baseboard_0
{"Model":"NVIDIA HGX B200 8 GPU","PartNumber":"935-26287-00A0-000","SerialNumber":"BB-1"}
`)
dumpC := []byte(`
# curl -X GET http://127.0.0.1/redfish/v1/Chassis/HGX_Tray_0/Assembly
{"Name":"HGX Tray Assembly","Model":"P6612-A04","PartNumber":"699-26612-0000-P00","SerialNumber":"TRAY-2"}
# curl -X GET http://127.0.0.1/redfish/v1/Systems/HGX_Baseboard_0
{"Model":"NVIDIA HGX B200 8 GPU","PartNumber":"935-26287-00A0-000","SerialNumber":"BB-2"}
`)
a := parseHGXIdentity(dumpA)
c := parseHGXIdentity(dumpC)
if a == nil || c == nil {
t.Fatal("expected identity from both dumps")
}
if a.Baseboard.SerialNumber == c.Baseboard.SerialNumber {
t.Fatal("expected baseboard serial to differ across dumps that recorded a swap")
}
if a.Tray.SerialNumber == c.Tray.SerialNumber {
t.Fatal("expected tray serial to differ across dumps that recorded a swap")
}
}
func TestParseHGXIdentity_TreatsNAAsAbsent(t *testing.T) {
content := []byte(`
# curl -X GET http://127.0.0.1/redfish/v1/Systems/HGX_Baseboard_0
{"Model":"NA","PartNumber":"NA","SerialNumber":"NA"}
`)
if identity := parseHGXIdentity(content); identity != nil {
t.Fatalf("expected nil identity when all fields are NA, got %+v", identity)
}
}
func TestParseHGXIdentity_NoHGXContentReturnsNil(t *testing.T) {
if identity := parseHGXIdentity(nil); identity != nil {
t.Fatalf("expected nil identity for empty content, got %+v", identity)
}
if identity := parseHGXIdentity([]byte("no redfish paths here")); identity != nil {
t.Fatalf("expected nil identity when no HGX paths present, got %+v", identity)
}
}
+49 -2
View File
@@ -16,7 +16,7 @@ import (
// parserVersion - version of this parser module // parserVersion - version of this parser module
// IMPORTANT: Increment this version when making changes to parser logic! // IMPORTANT: Increment this version when making changes to parser logic!
const parserVersion = "2.2" const parserVersion = "2.3"
func init() { func init() {
parser.Register(&Parser{}) parser.Register(&Parser{})
@@ -203,6 +203,26 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
} }
} }
// New dump_<serial>_<timestamp>/ layout has no devicefrusdr.log: FRU and
// sensors live in separate ipmitool-output text files under component/.
if parser.FindFileByName(files, "devicefrusdr.log") == nil {
if f := parser.FindFileByName(files, "fru.txt"); f != nil && len(result.FRU) == 0 {
result.FRU = ParseFRU(f.Content)
extractBoardInfo(result.FRU, result.Hardware)
}
if f := parser.FindFileByName(files, "sensor.txt"); f != nil && len(result.Sensors) == 0 {
result.Sensors = mergeSensorReadings(result.Sensors, ParseSensorList(f.Content))
} else if f := parser.FindFileByName(files, "sdr.txt"); f != nil && len(result.Sensors) == 0 {
result.Sensors = mergeSensorReadings(result.Sensors, ParseSDRElist(f.Content))
}
// Structural PCIe snapshot (GPU presence/link state) from the HGX diagnose dump.
if f := parser.FindFileByName(files, "OtrdDiagnoseComponent.json"); f != nil && result.Hardware != nil {
diagPCIe := ParseOtrdDiagnosePCIe(f.Content)
result.Hardware.PCIeDevices = MergePCIeDevices(result.Hardware.PCIeDevices, diagPCIe)
result.Events = append(result.Events, BuildPCIeLinkDegradationEvents(diagPCIe)...)
}
}
// Enrich runtime component data from Redis snapshot (serials, FW, telemetry), // Enrich runtime component data from Redis snapshot (serials, FW, telemetry),
// when text logs miss these fields. // when text logs miss these fields.
if f := parser.FindFileByName(files, "redis-dump.rdb"); f != nil && result.Hardware != nil { if f := parser.FindFileByName(files, "redis-dump.rdb"); f != nil && result.Hardware != nil {
@@ -216,10 +236,14 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
result.Events = append(result.Events, idlEvents...) result.Events = append(result.Events, idlEvents...)
} }
// Parse SEL list (selelist.csv) // Parse SEL list (selelist.csv), falling back to log/sel.csv on the
// dump_<serial>_<timestamp>/ layout that has no selelist.csv.
if f := parser.FindFileByName(files, "selelist.csv"); f != nil { if f := parser.FindFileByName(files, "selelist.csv"); f != nil {
selEvents := ParseSELListWithLocation(f.Content, selLocation) selEvents := ParseSELListWithLocation(f.Content, selLocation)
result.Events = append(result.Events, selEvents...) result.Events = append(result.Events, selEvents...)
} else if f := parser.FindFileByName(files, "sel.csv"); f != nil {
selEvents := ParseSELListWithLocation(f.Content, selLocation)
result.Events = append(result.Events, selEvents...)
} }
// Parse syslog files // Parse syslog files
@@ -229,6 +253,14 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
result.Events = append(result.Events, events...) result.Events = append(result.Events, events...)
} }
// Parse BMC component failure logs (log/bmc/commer-comp/*): HGX management
// controller, switch VR/power, switch CPLD and slot presence failures.
result.Events = append(result.Events, ParseCommerCompEvents(files, selLocation)...)
// Same SEL event can be reported twice by the BMC (e.g. once via sel.csv,
// once via idl.log); collapse exact duplicates so they don't double-count.
result.Events = dedupSELEvents(result.Events)
// Fallback for archives where board serial is missing in parsed FRU/asset data: // Fallback for archives where board serial is missing in parsed FRU/asset data:
// recover it from log content, never from archive filename. // recover it from log content, never from archive filename.
if strings.TrimSpace(result.Hardware.BoardInfo.SerialNumber) == "" { if strings.TrimSpace(result.Hardware.BoardInfo.SerialNumber) == "" {
@@ -246,6 +278,7 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
if f := parser.FindFileByName(files, "HGX_HWInfo_FWVersion.log"); f != nil && result.Hardware != nil { if f := parser.FindFileByName(files, "HGX_HWInfo_FWVersion.log"); f != nil && result.Hardware != nil {
enrichGPUsFromHGXHWInfo(f.Content, result.Hardware) enrichGPUsFromHGXHWInfo(f.Content, result.Hardware)
appendHGXFirmwareFromHWInfo(f.Content, result.Hardware) appendHGXFirmwareFromHWInfo(f.Content, result.Hardware)
result.Hardware.HGX = parseHGXIdentity(f.Content)
} }
// Mark problematic GPUs from IDL errors like "BIOS miss F_GPU6". // Mark problematic GPUs from IDL errors like "BIOS miss F_GPU6".
@@ -261,6 +294,20 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
parser.ApplyManufacturedYearWeekFromFRU(result.FRU, result.Hardware) parser.ApplyManufacturedYearWeekFromFRU(result.FRU, result.Hardware)
} }
if len(result.FRU) == 0 || len(result.Sensors) == 0 {
var missing []string
if len(result.FRU) == 0 {
missing = append(missing, "FRU")
}
if len(result.Sensors) == 0 {
missing = append(missing, "sensors")
}
result.CollectionErrors = append(result.CollectionErrors, models.CollectionError{
Section: "inventory",
Message: fmt.Sprintf("inventory sources not found: devicefrusdr.log absent, fell back to component/fru.txt+sensor.txt/sdr.txt, still missing: %s", strings.Join(missing, ", ")),
})
}
return result, nil return result, nil
} }
+6
View File
@@ -314,6 +314,12 @@ func enrichPCIeDevice(dst *models.PCIeDevice, src models.PCIeDevice) {
if isGenericPCIeClass(dst.DeviceClass) && !isGenericPCIeClass(src.DeviceClass) { if isGenericPCIeClass(dst.DeviceClass) && !isGenericPCIeClass(src.DeviceClass) {
dst.DeviceClass = src.DeviceClass dst.DeviceClass = src.DeviceClass
} }
if dst.Present == nil {
dst.Present = src.Present
}
if strings.TrimSpace(dst.Status) == "" {
dst.Status = src.Status
}
} }
func normalizePCIeBDF(bdf string) string { func normalizePCIeBDF(bdf string) string {
+26
View File
@@ -176,6 +176,32 @@ func determineSELSeverity(sensorStr, eventDesc, status string) models.Severity {
return models.SeverityInfo return models.SeverityInfo
} }
// dedupSELEvents collapses events reported more than once with the same
// (timestamp, event_type, description) triple. Unlike ParseIDLLog's
// dedup (which must keep recurring alarms with distinct timestamps), this
// only removes true duplicates: the same SEL entry surfacing through more
// than one source file for the exact same moment.
func dedupSELEvents(events []models.Event) []models.Event {
if len(events) == 0 {
return events
}
seen := make(map[string]struct{}, len(events))
out := make([]models.Event, 0, len(events))
for _, e := range events {
if e.Source != "SEL" {
out = append(out, e)
continue
}
key := e.Timestamp.String() + "|" + e.EventType + "|" + e.Description
if _, ok := seen[key]; ok {
continue
}
seen[key] = struct{}{}
out = append(out, e)
}
return out
}
// buildSELDescription builds human-readable description // buildSELDescription builds human-readable description
func buildSELDescription(eventDesc, status string) string { func buildSELDescription(eventDesc, status string) string {
if status == "Asserted" || status == "Deasserted" { if status == "Asserted" || status == "Deasserted" {
+17
View File
@@ -3,8 +3,25 @@ package inspur
import ( import (
"testing" "testing"
"time" "time"
"git.mchus.pro/mchus/logpile/internal/models"
) )
func TestDedupSELEvents(t *testing.T) {
ts := time.Date(2026, 7, 27, 4, 52, 55, 0, time.UTC)
events := []models.Event{
{Source: "SEL", Timestamp: ts, EventType: "Asserted", Description: "PSU0 fail"},
{Source: "SEL", Timestamp: ts, EventType: "Asserted", Description: "PSU0 fail"},
{Source: "BMC", Timestamp: ts, EventType: "Assert", Description: "recurring alarm"},
{Source: "BMC", Timestamp: ts, EventType: "Assert", Description: "recurring alarm"},
}
out := dedupSELEvents(events)
if len(out) != 3 {
t.Fatalf("expected 3 events (1 SEL dup removed, BMC untouched), got %d: %+v", len(out), out)
}
}
func TestParseSELListWithLocation_UsesProvidedTimezone(t *testing.T) { func TestParseSELListWithLocation_UsesProvidedTimezone(t *testing.T) {
content := []byte("sel elist:\n1,02/28/2026,04:18:18,Sensor X,Event,Asserted\n") content := []byte("sel elist:\n1,02/28/2026,04:18:18,Sensor X,Event,Asserted\n")
shanghai, err := time.LoadLocation("Asia/Shanghai") shanghai, err := time.LoadLocation("Asia/Shanghai")
+757 -2030
View File
File diff suppressed because it is too large Load Diff