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
|
||||
}
|
||||
Reference in new issue
Block a user