feat: surface BMC collection errors in parse-errors panel and event log
When Inspur component.log sections return {"error":"...","code":N} instead
of hardware data, the parser now:
- stores them in AnalysisResult.CollectionErrors (new model field)
- mirrors each one into result.Events with Source="BMC/<section>"
so the chart viewer event table shows the specific BMC module
- feeds them into /api/parse-errors as bmc_collection_error entries
UI adds a collapsible "Collection diagnostics" panel below the chart
iframe (outside /chart) that appears when /api/parse-errors returns
any items; resets on data clear.
Affected sections in this dump: HDD (1458), PCIe Devices (1458),
Network Adapters (1458), Disk Backplane.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+46
@@ -56,6 +56,52 @@ func ParseComponentLogEvents(content []byte) []models.Event {
|
||||
return events
|
||||
}
|
||||
|
||||
// ParseComponentLogCollectionErrors detects BMC-reported collection failures in component.log.
|
||||
// When a RESTful section returns {"error":"...","code":N} instead of structured data,
|
||||
// the BMC itself failed to collect that subsystem — the parser emits a CollectionError
|
||||
// so the UI can surface it explicitly rather than showing an empty section.
|
||||
func ParseComponentLogCollectionErrors(content []byte) []models.CollectionError {
|
||||
type bmcErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
Code int `json:"code"`
|
||||
}
|
||||
|
||||
// Map of section name (for display) → regex that captures its JSON payload.
|
||||
// Sections that return arrays use \[ ... \]; object sections use \{ ... \}.
|
||||
// We only probe sections that are expected to have structured hardware data.
|
||||
sections := []struct {
|
||||
name string
|
||||
re *regexp.Regexp
|
||||
}{
|
||||
{"HDD", regexp.MustCompile(`RESTful HDD info:\s*(\{[^\n]*\})`)},
|
||||
{"PCIe Devices", regexp.MustCompile(`RESTful PCIE Device info:\s*(\{[^\n]*\})`)},
|
||||
{"Network Adapters", regexp.MustCompile(`RESTful Network Adapter info:\s*(\{[^\n]*\})`)},
|
||||
{"Disk Backplane", regexp.MustCompile(`RESTful diskbackplane info:\s*(\{[^\n]*\})`)},
|
||||
}
|
||||
|
||||
text := string(content)
|
||||
var out []models.CollectionError
|
||||
for _, s := range sections {
|
||||
m := s.re.FindStringSubmatch(text)
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
var errResp bmcErrorResponse
|
||||
if err := json.Unmarshal([]byte(m[1]), &errResp); err != nil {
|
||||
continue
|
||||
}
|
||||
if strings.TrimSpace(errResp.Error) == "" {
|
||||
continue
|
||||
}
|
||||
out = append(out, models.CollectionError{
|
||||
Section: s.name,
|
||||
Message: errResp.Error,
|
||||
Code: errResp.Code,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ParseComponentLogSensors extracts sensor readings from component.log JSON sections.
|
||||
func ParseComponentLogSensors(content []byte) []models.SensorReading {
|
||||
text := string(content)
|
||||
|
||||
Reference in New Issue
Block a user