- cpu.go: collectCPUs(), parseCPUs(), parseCPUSection() - splitDMISections(): splits multi-section dmidecode output generically - parseFieldLines(): reusable key→value parser for DMI sections - parseCPUStatus(): Populated/Unpopulated → OK/WARNING/EMPTY/UNKNOWN - parseSocketIndex(): CPU0/Processor 1/Socket 2 → integer - cleanManufacturer(): strips (R), Corporation, Inc. suffixes - parseMHz(), parseInt(): field value parsers - Serial fallback: <board_serial>-CPU-<socket> when DMI serial absent - readMicrocode(): /sys/devices/system/cpu/cpu0/microcode/version - cpu_test.go: dual-socket, unpopulated skipped, status, socket, manufacturer, MHz Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
// Package collector runs all hardware collectors and merges results
|
||
// into a single HardwareSnapshot. Each sub-collector is independent:
|
||
// a failure in one does not abort the others.
|
||
package collector
|
||
|
||
import (
|
||
"bee/audit/internal/schema"
|
||
"log/slog"
|
||
"time"
|
||
)
|
||
|
||
// Run executes all collectors and returns the combined snapshot.
|
||
// Partial failures are logged as warnings; collection always completes.
|
||
func Run() schema.HardwareIngestRequest {
|
||
start := time.Now()
|
||
slog.Info("audit started")
|
||
|
||
snap := schema.HardwareSnapshot{}
|
||
|
||
board, biosFW := collectBoard()
|
||
snap.Board = board
|
||
snap.Firmware = append(snap.Firmware, biosFW...)
|
||
|
||
cpus, cpuFW := collectCPUs(snap.Board.SerialNumber)
|
||
snap.CPUs = cpus
|
||
snap.Firmware = append(snap.Firmware, cpuFW...)
|
||
|
||
// remaining collectors added in steps 1.4 – 1.10
|
||
|
||
slog.Info("audit completed", "duration", time.Since(start).Round(time.Millisecond))
|
||
|
||
sourceType := "livcd"
|
||
protocol := "os-direct"
|
||
|
||
return schema.HardwareIngestRequest{
|
||
SourceType: &sourceType,
|
||
Protocol: &protocol,
|
||
CollectedAt: time.Now().UTC().Format(time.RFC3339),
|
||
Hardware: snap,
|
||
}
|
||
}
|