feat(inspur): keep DIMM state on the DIMM, parse maintenance.log installs
component.log memory status produced synthetic "Memory module … not detected (capacity 0GB)" events that duplicated IDL/SEL "Memory Device Disabled … POR Mapout" Asserts already in the journal, with a wrong text (the modules are present). - Drop synthetic memory events. The snapshot status stays authoritative on the DIMM; the journal Assert/Deassert supplies status_history, the fault description and status_changed_at (latest active Assert). - Drop a component.log fan state event when the journal already holds an active Assert for that fan. - Parse "Component Replace <dev> SN changed from X to Y" from maintenance.log and rotated maintenance.log.N.gz into Info events, mapping DIMM<cpu><ch><dimm> to the inventory slot (DIMM021 -> CPU0_C2D1). ADL-071. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f2ad0aca96
commit
693906ceba
7 files changed
+421
-57
No files matched your search
+37
-57
@@ -46,17 +46,12 @@ func ParseComponentLog(content []byte, hw *models.HardwareConfig) {
|
||||
extractComponentFirmware(text, hw)
|
||||
}
|
||||
|
||||
// ParseComponentLogEvents extracts events from component.log (memory errors, etc.)
|
||||
// ParseComponentLogEvents extracts fan state reported in component.log.
|
||||
// It is a snapshot at log collection, not a journal entry: events carry no
|
||||
// timestamp. DIMM state is not emitted here: it lives on the DIMM itself
|
||||
// (see applyMemoryStatusFromEvents).
|
||||
func ParseComponentLogEvents(content []byte) []models.Event {
|
||||
var events []models.Event
|
||||
text := string(content)
|
||||
|
||||
// Parse RESTful Memory info for Warning/Error status
|
||||
memEvents := parseMemoryEvents(text)
|
||||
events = append(events, memEvents...)
|
||||
events = append(events, parseFanEvents(text)...)
|
||||
|
||||
return events
|
||||
return parseFanEvents(string(content))
|
||||
}
|
||||
|
||||
// ParseComponentLogCollectionErrors detects BMC-reported collection failures in component.log.
|
||||
@@ -1093,6 +1088,38 @@ func parseFanEvents(text string) []models.Event {
|
||||
return events
|
||||
}
|
||||
|
||||
// dropFanSnapshotEventsCoveredByJournal removes component.log fan state
|
||||
// events when the BMC journal already holds an asserted fault for that fan:
|
||||
// the journal entry is the real, dated record of the same condition.
|
||||
func dropFanSnapshotEventsCoveredByJournal(events []models.Event) []models.Event {
|
||||
latest := make(map[string]models.Event)
|
||||
for _, event := range events {
|
||||
if !strings.EqualFold(strings.TrimSpace(event.SensorType), "fan") || event.Timestamp.IsZero() {
|
||||
continue
|
||||
}
|
||||
etype := strings.ToLower(strings.TrimSpace(event.EventType))
|
||||
if etype != "assert" && etype != "deassert" {
|
||||
continue
|
||||
}
|
||||
name := strings.ToUpper(strings.TrimSpace(event.SensorName))
|
||||
if prev, ok := latest[name]; !ok || !event.Timestamp.Before(prev.Timestamp) {
|
||||
latest[name] = event
|
||||
}
|
||||
}
|
||||
if len(latest) == 0 {
|
||||
return events
|
||||
}
|
||||
out := events[:0]
|
||||
for _, event := range events {
|
||||
last, ok := latest[strings.ToUpper(strings.TrimSpace(event.SensorName))]
|
||||
if event.EventType == "Fan Status" && ok && !eventIsDeassert(last) {
|
||||
continue
|
||||
}
|
||||
out = append(out, event)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func parseDiskBackplaneSensors(text string) []models.SensorReading {
|
||||
re := regexp.MustCompile(`RESTful diskbackplane info:\s*(\[[\s\S]*?\])\s*BMC`)
|
||||
match := re.FindStringSubmatch(text)
|
||||
@@ -1218,53 +1245,6 @@ func looksLikeRawDeviceID(v string) bool {
|
||||
return rawDeviceIDLikeRegex.MatchString(v)
|
||||
}
|
||||
|
||||
func parseMemoryEvents(text string) []models.Event {
|
||||
var events []models.Event
|
||||
|
||||
// Find RESTful Memory info section
|
||||
re := regexp.MustCompile(`RESTful Memory info:\s*(\{[\s\S]*?\})\s*RESTful HDD`)
|
||||
match := re.FindStringSubmatch(text)
|
||||
if match == nil {
|
||||
return events
|
||||
}
|
||||
|
||||
jsonStr := match[1]
|
||||
jsonStr = strings.ReplaceAll(jsonStr, "\n", "")
|
||||
|
||||
var memInfo MemoryRESTInfo
|
||||
if err := json.Unmarshal([]byte(jsonStr), &memInfo); err != nil {
|
||||
return events
|
||||
}
|
||||
|
||||
// Generate events for memory modules with Warning or Error status
|
||||
for _, mem := range memInfo.MemModules {
|
||||
if mem.Status == "Warning" || mem.Status == "Error" || mem.Status == "Critical" {
|
||||
severity := models.SeverityWarning
|
||||
if mem.Status == "Error" || mem.Status == "Critical" {
|
||||
severity = models.SeverityCritical
|
||||
}
|
||||
|
||||
description := fmt.Sprintf("Memory module %s: %s", mem.MemModSlot, mem.Status)
|
||||
if mem.MemModSize == 0 {
|
||||
description = fmt.Sprintf("Memory module %s not detected (capacity 0GB)", mem.MemModSlot)
|
||||
}
|
||||
|
||||
events = append(events, models.Event{
|
||||
ID: fmt.Sprintf("mem_%d", mem.MemModID),
|
||||
Source: "Memory",
|
||||
SensorType: "memory",
|
||||
SensorName: mem.MemModSlot,
|
||||
EventType: "Memory Status",
|
||||
Severity: severity,
|
||||
Description: description,
|
||||
RawData: fmt.Sprintf("Slot: %s, Vendor: %s, P/N: %s, S/N: %s", mem.MemModSlot, mem.MemModVendor, mem.MemModPartNum, mem.MemModSerial),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return events
|
||||
}
|
||||
|
||||
// extractComponentFirmware extracts firmware versions from all component data
|
||||
func extractComponentFirmware(text string, hw *models.HardwareConfig) {
|
||||
// Create a map to track existing firmware entries (avoid duplicates)
|
||||
|
||||
Reference in new issue
Block a user