feat(export): contract-conformant event_logs event_time and is_active
Reanimator contract v2.13 makes event_logs[].event_time optional
(Reanimator falls back to collection/ingest time) and defines is_active
("still active / not cleared").
- Omit event_time when the event has no source time instead of passing
collected_at off as the event time.
- is_active=true only from an authoritative active-alarm snapshot: Inspur
dev_status.log (IDL event ID / SEL sensor at the same instant) and
component.log fan state (new models.Event.Active). false for Deasserts,
superseded Asserts in a real Assert/Deassert lifecycle and Inspur
Warning/Critical Asserts missing from dev_status.log; unset otherwise.
A missing Deassert is not treated as active: AC loss and BMC resets drop
them (24C319575: PSU1 predictive failure).
- component.log fan events use source BMC instead of host.
- Request installed_at in the Reanimator contract to date component
installs from maintenance.log; follow-up in BACKLOG [installed_at].
ADL-072.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
693906ceba
commit
2ce60280c3
10 files changed
+423
-11
No files matched your search
+62
@@ -0,0 +1,62 @@
|
||||
package inspur
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.mchus.pro/mchus/logpile/internal/models"
|
||||
)
|
||||
|
||||
// applyActiveFromDeviceStatus marks journal alarms with the BMC's own
|
||||
// active-alarm snapshot (dev_status.log, taken at log collection). A
|
||||
// Warning/Critical Assert listed there is active; one missing from it is
|
||||
// not, even without a logged Deassert (AC loss or a BMC reset drops those).
|
||||
// Info-level asserts are one-shot notifications and stay unmarked.
|
||||
func applyActiveFromDeviceStatus(events, current []models.Event) {
|
||||
type activeAlarm struct {
|
||||
id string
|
||||
sensor string
|
||||
}
|
||||
bySecond := make(map[int64][]activeAlarm)
|
||||
for _, alarm := range current {
|
||||
if alarm.Timestamp.IsZero() || eventIsDeassert(alarm) {
|
||||
continue
|
||||
}
|
||||
sec := alarm.Timestamp.Unix()
|
||||
bySecond[sec] = append(bySecond[sec], activeAlarm{
|
||||
id: strings.ToUpper(strings.TrimSpace(alarm.ID)),
|
||||
sensor: strings.ToUpper(strings.TrimSpace(alarm.SensorName)),
|
||||
})
|
||||
}
|
||||
|
||||
for i := range events {
|
||||
event := &events[i]
|
||||
if event.Active != nil || event.Timestamp.IsZero() || !isAlarmSeverity(event.Severity) {
|
||||
continue
|
||||
}
|
||||
source := strings.ToUpper(strings.TrimSpace(event.Source))
|
||||
if source != "BMC" && source != "SEL" {
|
||||
continue
|
||||
}
|
||||
if eventIsDeassert(*event) {
|
||||
continue
|
||||
}
|
||||
active := false
|
||||
id := strings.ToUpper(strings.TrimSpace(event.ID))
|
||||
sensor := strings.ToUpper(strings.TrimSpace(event.SensorName))
|
||||
for _, alarm := range bySecond[event.Timestamp.Unix()] {
|
||||
// IDL records match by event ID; SEL records carry a record
|
||||
// number instead and match by sensor name at the same instant.
|
||||
if (source == "BMC" && id == alarm.id) ||
|
||||
(source == "SEL" && sensor != "" && alarm.sensor != "" &&
|
||||
(strings.Contains(sensor, alarm.sensor) || strings.Contains(alarm.sensor, sensor))) {
|
||||
active = true
|
||||
break
|
||||
}
|
||||
}
|
||||
event.Active = &active
|
||||
}
|
||||
}
|
||||
|
||||
func isAlarmSeverity(severity models.Severity) bool {
|
||||
return severity == models.SeverityWarning || severity == models.SeverityCritical
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package inspur
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.mchus.pro/mchus/logpile/internal/models"
|
||||
)
|
||||
|
||||
func TestApplyActiveFromDeviceStatus(t *testing.T) {
|
||||
loc := time.FixedZone("+08", 8*3600)
|
||||
mapout := time.Date(2026, 8, 12, 19, 23, 50, 0, loc)
|
||||
psu := time.Date(2026, 8, 11, 19, 8, 50, 0, loc)
|
||||
events := []models.Event{
|
||||
{Timestamp: mapout, Source: "BMC", SensorName: "CPU0_C2D1", ID: "0C090401", EventType: "Assert", Severity: models.SeverityWarning},
|
||||
{Timestamp: mapout, Source: "SEL", SensorName: "CPU0_C2D1", ID: "69", EventType: "Memory Device Disabled", RawData: "Asserted", Severity: models.SeverityWarning},
|
||||
{Timestamp: psu, Source: "BMC", SensorName: "PSU1", ID: "08010201", EventType: "Assert", Severity: models.SeverityWarning},
|
||||
{Timestamp: psu, Source: "BMC", SensorName: "PSU1", ID: "08010000", EventType: "Assert", Severity: models.SeverityInfo},
|
||||
}
|
||||
current := []models.Event{
|
||||
{Timestamp: mapout, Source: "BMC", SensorName: "CPU0_C2D1", ID: "0C090401", EventType: "Assert", Severity: models.SeverityWarning},
|
||||
}
|
||||
|
||||
applyActiveFromDeviceStatus(events, current)
|
||||
|
||||
if events[0].Active == nil || !*events[0].Active {
|
||||
t.Fatalf("IDL alarm listed in dev_status must be active")
|
||||
}
|
||||
if events[1].Active == nil || !*events[1].Active {
|
||||
t.Fatalf("SEL record of the same alarm must be active")
|
||||
}
|
||||
if events[2].Active == nil || *events[2].Active {
|
||||
t.Fatalf("alarm missing from dev_status must be inactive even without Deassert")
|
||||
}
|
||||
if events[3].Active != nil {
|
||||
t.Fatalf("info notification must stay unmarked")
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -48,8 +48,8 @@ func ParseComponentLog(content []byte, hw *models.HardwareConfig) {
|
||||
|
||||
// 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).
|
||||
// timestamp and are marked active. DIMM state is not emitted here: it lives
|
||||
// on the DIMM itself (see applyMemoryStatusFromEvents).
|
||||
func ParseComponentLogEvents(content []byte) []models.Event {
|
||||
return parseFanEvents(string(content))
|
||||
}
|
||||
@@ -1073,15 +1073,17 @@ func parseFanEvents(text string) []models.Event {
|
||||
severity = models.SeverityCritical
|
||||
}
|
||||
|
||||
active := true
|
||||
events = append(events, models.Event{
|
||||
ID: fmt.Sprintf("fan_%d_status", fan.ID),
|
||||
Source: "Fan",
|
||||
Source: "BMC",
|
||||
SensorType: "fan",
|
||||
SensorName: name,
|
||||
EventType: "Fan Status",
|
||||
Severity: severity,
|
||||
Description: fmt.Sprintf("%s reports %s", name, status),
|
||||
RawData: fmt.Sprintf("rpm=%d pct=%d model=%s", fan.SpeedRPM, fan.SpeedPercent, fan.FanModel),
|
||||
Active: &active,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -326,6 +326,9 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
|
||||
currentDeviceEvents = ParseIDLLog(f.Content)
|
||||
}
|
||||
applyStorageStatusFromEvents(result.Hardware, result.Events, currentDeviceEvents, currentDeviceSnapshotAvailable)
|
||||
if currentDeviceSnapshotAvailable {
|
||||
applyActiveFromDeviceStatus(result.Events, currentDeviceEvents)
|
||||
}
|
||||
enrichStorageFromSerialFallbackFiles(files, result.Hardware)
|
||||
// Enrich storage serial numbers from smartd output in SOLHostCapture.log.
|
||||
// Fills in serial, model, firmware for backplane slots that the BMC HDD API left empty.
|
||||
|
||||
Reference in new issue
Block a user