Files
logpile/internal/parser/vendors/inspur_legacy/idl.go
T
Mikhail ChusavitinandClaude Sonnet 5 3311bafd8e feat(inspur_legacy): new parser for pre-Kaytus Inspur onekeylog
Older AMI-BMC Inspur onekeylog archives (NF5466M5 / NF5280M5 generation)
opened to an empty result: they carry none of the files the inspur parser
keys on (no asset.json, devicefrusdr.log, selelist.csv or component.log).

New package internal/parser/vendors/inspur_legacy (vendor id inspur_legacy),
separate from inspur:
- binary IPMI FRU decode (FRU.bin) -> board identity
- Inspur_AssetInfoInventory.log -> CPU / memory / PCIe / PSU inventory
- events from Inspur_<model>_<serial>_IDL, sel.log, blackbox.log,
  MegaRAID raid0.log, and the flat AMI <severity>.log files
- no live sensors in this archive class -> recorded as a collection error
- BMC clock timestamps before 2010 dropped as un-set (1970 / ~2005 RTC)

Registry: add optional PrioritizedParser { DetectPriority() int } so a
confidence tie is broken by specificity. inspur_legacy returns 10 and also
declines (Detect 0) when modern Kaytus markers are present, so the two
Inspur parsers never fight over a newer dump.

Docs: ADL-065, 06-parsers.md, releases/v1.32.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VL8wLGD6Lnp6hZCpqT6cZ
2026-09-02 12:51:53 +03:00

62 lines
1.6 KiB
Go

package inspurlegacy
import (
"strings"
"time"
"git.mchus.pro/mchus/logpile/internal/models"
)
// idlTimeLayout is the naive local timestamp used by the legacy IDL log; it
// carries no timezone offset.
const idlTimeLayout = "2006-01-02T15:04:05"
// ParseIDLEvents parses the "Inspur_<model>_<serial>_IDL" event log. Each line
// is "timestamp|component|severity|assertion|code|description".
func ParseIDLEvents(content []byte) []models.Event {
var events []models.Event
for _, line := range strings.Split(string(content), "\n") {
line = strings.TrimRight(line, "\r ")
if line == "" {
continue
}
parts := strings.Split(line, "|")
if len(parts) < 6 {
continue
}
ts, err := time.Parse(idlTimeLayout, strings.TrimSpace(parts[0]))
if err != nil {
continue
}
component := strings.TrimSpace(parts[1])
severityWord := strings.TrimSpace(parts[2])
assertion := strings.TrimSpace(parts[3])
code := strings.TrimSpace(parts[4])
desc := strings.TrimSpace(strings.Join(parts[5:], "|"))
desc = strings.TrimRight(desc, ".")
if bogusYear(ts) {
// Pre-NTP boot spam with no real wall-clock time.
continue
}
severity := severityFromWord(severityWord)
if strings.Contains(strings.ToLower(assertion), "deassert") {
severity = models.SeverityInfo
}
events = append(events, models.Event{
ID: "idl_" + code + "_" + ts.Format("20060102T150405"),
Timestamp: ts,
Source: "BMC/IDL",
SensorType: strings.ToLower(component),
SensorName: component,
EventType: assertion,
Severity: severity,
Description: desc,
RawData: line,
})
}
return events
}