v1.1.0: Parser versioning, server info, auto-browser, section overviews
- Add parser versioning with Version() method and version display on main screen - Add server model and serial number to Configuration tab and TXT export - Add auto-browser opening on startup with --no-browser flag - Add Restart and Exit buttons with graceful shutdown - Add section overview stats (CPU, Power, Storage, GPU, Network) - Change PCIe Link display to "x16 PCIe Gen4" format - Add Location column to Serials section - Extract BoardInfo from FRU and PlatformId from ThermalConfig Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,7 @@ func (e *Exporter) ExportCSV(w io.Writer) error {
|
||||
defer writer.Flush()
|
||||
|
||||
// Header
|
||||
if err := writer.Write([]string{"Component", "Serial Number", "Manufacturer", "Part Number"}); err != nil {
|
||||
if err := writer.Write([]string{"Component", "Serial Number", "Manufacturer", "Location"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -59,11 +59,15 @@ func (e *Exporter) ExportCSV(w io.Writer) error {
|
||||
if mem.SerialNumber == "" {
|
||||
continue
|
||||
}
|
||||
location := mem.Location
|
||||
if location == "" {
|
||||
location = mem.Slot
|
||||
}
|
||||
if err := writer.Write([]string{
|
||||
fmt.Sprintf("DIMM Slot %d (%s)", mem.Slot, mem.PartNumber),
|
||||
mem.PartNumber,
|
||||
mem.SerialNumber,
|
||||
mem.Manufacturer,
|
||||
mem.PartNumber,
|
||||
location,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -75,10 +79,10 @@ func (e *Exporter) ExportCSV(w io.Writer) error {
|
||||
continue
|
||||
}
|
||||
if err := writer.Write([]string{
|
||||
fmt.Sprintf("%s %s", stor.Type, stor.Model),
|
||||
stor.Model,
|
||||
stor.SerialNumber,
|
||||
"",
|
||||
"",
|
||||
stor.Manufacturer,
|
||||
stor.Slot,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -90,10 +94,10 @@ func (e *Exporter) ExportCSV(w io.Writer) error {
|
||||
continue
|
||||
}
|
||||
if err := writer.Write([]string{
|
||||
fmt.Sprintf("%s (%s)", pcie.DeviceClass, pcie.Slot),
|
||||
pcie.DeviceClass,
|
||||
pcie.SerialNumber,
|
||||
"",
|
||||
pcie.PartNumber,
|
||||
pcie.Manufacturer,
|
||||
pcie.Slot,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -121,7 +125,15 @@ func (e *Exporter) ExportTXT(w io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "File: %s\n\n", e.result.Filename)
|
||||
fmt.Fprintf(w, "File: %s\n", e.result.Filename)
|
||||
|
||||
// Server model and serial number
|
||||
if e.result.Hardware != nil && e.result.Hardware.BoardInfo.ProductName != "" {
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintf(w, "Server Model: %s\n", e.result.Hardware.BoardInfo.ProductName)
|
||||
fmt.Fprintf(w, "Serial Number: %s\n", e.result.Hardware.BoardInfo.SerialNumber)
|
||||
}
|
||||
fmt.Fprintln(w)
|
||||
|
||||
// Hardware summary
|
||||
if e.result.Hardware != nil {
|
||||
|
||||
@@ -12,6 +12,10 @@ type VendorParser interface {
|
||||
// Vendor returns vendor identifier (e.g., "inspur", "supermicro", "dell")
|
||||
Vendor() string
|
||||
|
||||
// Version returns parser version string
|
||||
// IMPORTANT: Increment version when modifying parser logic!
|
||||
Version() string
|
||||
|
||||
// Detect checks if this parser can handle the given files
|
||||
// Returns confidence score 0-100 (0 = cannot parse, 100 = definitely this format)
|
||||
Detect(files []ExtractedFile) int
|
||||
|
||||
@@ -46,6 +46,35 @@ func ListParsers() []string {
|
||||
return vendors
|
||||
}
|
||||
|
||||
// ParserInfo contains information about a registered parser
|
||||
type ParserInfo struct {
|
||||
Vendor string `json:"vendor"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// ListParsersInfo returns detailed info about all registered parsers
|
||||
func ListParsersInfo() []ParserInfo {
|
||||
registryLock.RLock()
|
||||
defer registryLock.RUnlock()
|
||||
|
||||
parsers := make([]ParserInfo, 0, len(registry))
|
||||
for _, p := range registry {
|
||||
parsers = append(parsers, ParserInfo{
|
||||
Vendor: p.Vendor(),
|
||||
Name: p.Name(),
|
||||
Version: p.Version(),
|
||||
})
|
||||
}
|
||||
|
||||
// Sort by vendor name
|
||||
sort.Slice(parsers, func(i, j int) bool {
|
||||
return parsers[i].Vendor < parsers[j].Vendor
|
||||
})
|
||||
|
||||
return parsers
|
||||
}
|
||||
|
||||
// DetectResult holds detection result for a parser
|
||||
type DetectResult struct {
|
||||
Parser VendorParser
|
||||
|
||||
68
internal/parser/vendors/inspur/fru.go
vendored
68
internal/parser/vendors/inspur/fru.go
vendored
@@ -9,8 +9,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
fruDeviceRegex = regexp.MustCompile(`^FRU Device Description\s*:\s*(.+)$`)
|
||||
fruFieldRegex = regexp.MustCompile(`^\s+(.+?)\s*:\s*(.*)$`)
|
||||
fruDeviceRegex = regexp.MustCompile(`^FRU Device Description\s*:\s*(.+)$`)
|
||||
fruFieldRegex = regexp.MustCompile(`^\s+(.+?)\s*:\s*(.*)$`)
|
||||
platformIdRegex = regexp.MustCompile(`(?i)PlatformId\s*=\s*(\S+)`)
|
||||
)
|
||||
|
||||
// ParseFRU parses BMC FRU (Field Replaceable Unit) output
|
||||
@@ -95,3 +96,66 @@ func ParseFRU(content []byte) []models.FRUInfo {
|
||||
|
||||
return fruList
|
||||
}
|
||||
|
||||
// extractBoardInfo extracts main board/chassis information from FRU data
|
||||
func extractBoardInfo(fruList []models.FRUInfo, hw *models.HardwareConfig) {
|
||||
if hw == nil || len(fruList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// Look for the main board/chassis FRU entry
|
||||
// Usually it's the first entry or one with "Builtin FRU" or containing board info
|
||||
for _, fru := range fruList {
|
||||
// Skip empty entries
|
||||
if fru.ProductName == "" && fru.SerialNumber == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Prioritize entries that look like main board info
|
||||
desc := strings.ToLower(fru.Description)
|
||||
isMainBoard := strings.Contains(desc, "builtin") ||
|
||||
strings.Contains(desc, "fru device") ||
|
||||
strings.Contains(desc, "chassis") ||
|
||||
strings.Contains(desc, "board")
|
||||
|
||||
// If we haven't set board info yet, or this is a main board entry
|
||||
if hw.BoardInfo.ProductName == "" || isMainBoard {
|
||||
if fru.ProductName != "" {
|
||||
hw.BoardInfo.ProductName = fru.ProductName
|
||||
}
|
||||
if fru.SerialNumber != "" {
|
||||
hw.BoardInfo.SerialNumber = fru.SerialNumber
|
||||
}
|
||||
if fru.Manufacturer != "" {
|
||||
hw.BoardInfo.Manufacturer = fru.Manufacturer
|
||||
}
|
||||
if fru.PartNumber != "" {
|
||||
hw.BoardInfo.PartNumber = fru.PartNumber
|
||||
}
|
||||
|
||||
// If we found a main board entry, stop searching
|
||||
if isMainBoard && fru.ProductName != "" && fru.SerialNumber != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// extractPlatformId extracts server model from ThermalConfig (PlatformId)
|
||||
func extractPlatformId(content []byte, hw *models.HardwareConfig) {
|
||||
if hw == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if match := platformIdRegex.FindSubmatch(content); match != nil {
|
||||
platformId := strings.TrimSpace(string(match[1]))
|
||||
if platformId != "" {
|
||||
// Set as ProductName (server model) - this takes priority over FRU data
|
||||
hw.BoardInfo.ProductName = platformId
|
||||
// Also set manufacturer as Inspur if not already set
|
||||
if hw.BoardInfo.Manufacturer == "" {
|
||||
hw.BoardInfo.Manufacturer = "Inspur"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
29
internal/parser/vendors/inspur/parser.go
vendored
29
internal/parser/vendors/inspur/parser.go
vendored
@@ -1,5 +1,8 @@
|
||||
// Package inspur provides parser for Inspur/Kaytus BMC diagnostic archives
|
||||
// Tested with: Kaytus KR4268X2 (onekeylog format)
|
||||
// Tested with: Inspur NF5468M7 / Kaytus KR4268X2 (onekeylog format)
|
||||
//
|
||||
// IMPORTANT: Increment parserVersion when modifying parser logic!
|
||||
// This helps track which version was used to parse specific logs.
|
||||
package inspur
|
||||
|
||||
import (
|
||||
@@ -9,6 +12,10 @@ import (
|
||||
"git.mchus.pro/mchus/logpile/internal/parser"
|
||||
)
|
||||
|
||||
// parserVersion - version of this parser module
|
||||
// IMPORTANT: Increment this version when making changes to parser logic!
|
||||
const parserVersion = "1.0.0"
|
||||
|
||||
func init() {
|
||||
parser.Register(&Parser{})
|
||||
}
|
||||
@@ -26,6 +33,12 @@ func (p *Parser) Vendor() string {
|
||||
return "inspur"
|
||||
}
|
||||
|
||||
// Version returns parser version
|
||||
// IMPORTANT: Update parserVersion constant when modifying parser logic!
|
||||
func (p *Parser) Version() string {
|
||||
return parserVersion
|
||||
}
|
||||
|
||||
// Detect checks if archive matches Inspur/Kaytus format
|
||||
// Returns confidence 0-100
|
||||
func (p *Parser) Detect(files []parser.ExtractedFile) int {
|
||||
@@ -90,11 +103,19 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
|
||||
}
|
||||
}
|
||||
|
||||
// Extract BoardInfo from FRU data
|
||||
if result.Hardware == nil {
|
||||
result.Hardware = &models.HardwareConfig{}
|
||||
}
|
||||
extractBoardInfo(result.FRU, result.Hardware)
|
||||
|
||||
// Extract PlatformId (server model) from ThermalConfig
|
||||
if f := parser.FindFileByName(files, "ThermalConfig_Cur.conf"); f != nil {
|
||||
extractPlatformId(f.Content, result.Hardware)
|
||||
}
|
||||
|
||||
// Parse component.log for additional data (PSU, etc.)
|
||||
if f := parser.FindFileByName(files, "component.log"); f != nil {
|
||||
if result.Hardware == nil {
|
||||
result.Hardware = &models.HardwareConfig{}
|
||||
}
|
||||
ParseComponentLog(f.Content, result.Hardware)
|
||||
|
||||
// Extract events from component.log (memory errors, etc.)
|
||||
|
||||
@@ -5,7 +5,9 @@ import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.mchus.pro/mchus/logpile/internal/exporter"
|
||||
"git.mchus.pro/mchus/logpile/internal/models"
|
||||
@@ -74,7 +76,7 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) handleGetParsers(w http.ResponseWriter, r *http.Request) {
|
||||
jsonResponse(w, map[string]interface{}{
|
||||
"parsers": parser.ListParsers(),
|
||||
"parsers": parser.ListParsersInfo(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -232,6 +234,7 @@ func (s *Server) handleGetSerials(w http.ResponseWriter, r *http.Request) {
|
||||
// Collect all serial numbers from various sources
|
||||
type SerialEntry struct {
|
||||
Component string `json:"component"`
|
||||
Location string `json:"location,omitempty"`
|
||||
SerialNumber string `json:"serial_number"`
|
||||
Manufacturer string `json:"manufacturer,omitempty"`
|
||||
PartNumber string `json:"part_number,omitempty"`
|
||||
@@ -282,6 +285,7 @@ func (s *Server) handleGetSerials(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
serials = append(serials, SerialEntry{
|
||||
Component: cpu.Model,
|
||||
Location: fmt.Sprintf("CPU%d", cpu.Socket),
|
||||
SerialNumber: sn,
|
||||
Category: "CPU",
|
||||
})
|
||||
@@ -292,8 +296,13 @@ func (s *Server) handleGetSerials(w http.ResponseWriter, r *http.Request) {
|
||||
if mem.SerialNumber == "" {
|
||||
continue
|
||||
}
|
||||
location := mem.Location
|
||||
if location == "" {
|
||||
location = mem.Slot
|
||||
}
|
||||
serials = append(serials, SerialEntry{
|
||||
Component: mem.PartNumber,
|
||||
Location: location,
|
||||
SerialNumber: mem.SerialNumber,
|
||||
Manufacturer: mem.Manufacturer,
|
||||
PartNumber: mem.PartNumber,
|
||||
@@ -308,9 +317,9 @@ func (s *Server) handleGetSerials(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
serials = append(serials, SerialEntry{
|
||||
Component: stor.Model,
|
||||
Location: stor.Slot,
|
||||
SerialNumber: stor.SerialNumber,
|
||||
Manufacturer: stor.Manufacturer,
|
||||
PartNumber: stor.Slot,
|
||||
Category: "Storage",
|
||||
})
|
||||
}
|
||||
@@ -321,7 +330,8 @@ func (s *Server) handleGetSerials(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
serials = append(serials, SerialEntry{
|
||||
Component: pcie.DeviceClass + " (" + pcie.Slot + ")",
|
||||
Component: pcie.DeviceClass,
|
||||
Location: pcie.Slot,
|
||||
SerialNumber: pcie.SerialNumber,
|
||||
Manufacturer: pcie.Manufacturer,
|
||||
PartNumber: pcie.PartNumber,
|
||||
@@ -348,8 +358,9 @@ func (s *Server) handleGetSerials(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
serials = append(serials, SerialEntry{
|
||||
Component: psu.Model,
|
||||
Location: psu.Slot,
|
||||
SerialNumber: psu.SerialNumber,
|
||||
PartNumber: psu.Slot,
|
||||
Manufacturer: psu.Vendor,
|
||||
Category: "PSU",
|
||||
})
|
||||
}
|
||||
@@ -510,6 +521,20 @@ func (s *Server) handleClear(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleShutdown(w http.ResponseWriter, r *http.Request) {
|
||||
jsonResponse(w, map[string]string{
|
||||
"status": "ok",
|
||||
"message": "Server shutting down",
|
||||
})
|
||||
|
||||
// Shutdown in a goroutine so the response can be sent
|
||||
go func() {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
s.Shutdown()
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
|
||||
func jsonResponse(w http.ResponseWriter, data interface{}) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(data)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.mchus.pro/mchus/logpile/internal/models"
|
||||
)
|
||||
@@ -19,8 +21,9 @@ type Config struct {
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
config Config
|
||||
mux *http.ServeMux
|
||||
config Config
|
||||
mux *http.ServeMux
|
||||
httpServer *http.Server
|
||||
|
||||
mu sync.RWMutex
|
||||
result *models.AnalysisResult
|
||||
@@ -60,11 +63,25 @@ func (s *Server) setupRoutes() {
|
||||
s.mux.HandleFunc("GET /api/export/json", s.handleExportJSON)
|
||||
s.mux.HandleFunc("GET /api/export/txt", s.handleExportTXT)
|
||||
s.mux.HandleFunc("DELETE /api/clear", s.handleClear)
|
||||
s.mux.HandleFunc("POST /api/shutdown", s.handleShutdown)
|
||||
}
|
||||
|
||||
func (s *Server) Run() error {
|
||||
addr := fmt.Sprintf(":%d", s.config.Port)
|
||||
return http.ListenAndServe(addr, s.mux)
|
||||
s.httpServer = &http.Server{
|
||||
Addr: addr,
|
||||
Handler: s.mux,
|
||||
}
|
||||
return s.httpServer.ListenAndServe()
|
||||
}
|
||||
|
||||
// Shutdown gracefully shuts down the server
|
||||
func (s *Server) Shutdown() {
|
||||
if s.httpServer != nil {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
s.httpServer.Shutdown(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// SetResult sets the analysis result (thread-safe)
|
||||
|
||||
Reference in New Issue
Block a user