[Feature] Expand system info bar to include memory, disk, CPU, and OS details (#952)

* collect OS info

* Fix systeminfo

* Fix it

* optimize it

* Add disk info

* add ethernet info

* add ethernet

* remove speed from ethernet

* add cpu info

* chore cleanup data

* chore fix podman

* restruct systeminfo

* use short cpu name

* debug memory

* collect and show memory

* remove os from the table

* truncate nic name

* chore: shorter names in json

* collect memory info

* add debug

* undo memory

* revert package.json

* fix conflicts

* fix conflixts

* Fix MacOs os family

* add ISP data for remote systems

* reorder the system page bar information

* remove OS from the system table

* Update with main

* Fix vulcheck

* Fix systembar

* fix system bar

* fix vulcheck

* update struct with static info

* Adjust collection method to upon agent connection
This commit is contained in:
Sven van Ginkel
2025-12-13 22:11:31 +01:00
committed by GitHub
parent 35329abcbd
commit d71714cbba
11 changed files with 504 additions and 62 deletions

View File

@@ -22,6 +22,14 @@ import (
gossh "golang.org/x/crypto/ssh"
)
const (
// StaticInfoIntervalMs defines the cache time threshold for including static system info
// Requests with cache time >= this value will include static info (reduces bandwidth)
// Note: uint16 max is 65535, so we can't use 15 minutes directly. The hub will make
// periodic requests at this interval.
StaticInfoIntervalMs uint16 = 60_001 // Just above the standard 60s interval
)
type Agent struct {
sync.Mutex // Used to lock agent while collecting data
debug bool // true if LOG_LEVEL is set to debug
@@ -37,7 +45,8 @@ type Agent struct {
netInterfaceDeltaTrackers map[uint16]*deltatracker.DeltaTracker[string, uint64] // Per-cache-time NIC delta trackers
dockerManager *dockerManager // Manages Docker API requests
sensorConfig *SensorConfig // Sensors config
systemInfo system.Info // Host system info
systemInfo system.Info // Host system info (dynamic dashboard data)
staticSystemInfo system.StaticInfo // Static system info (collected at longer intervals)
gpuManager *GPUManager // Manages GPU data
cache *systemDataCache // Cache for system stats based on cache time
connectionManager *ConnectionManager // Channel to signal connection events
@@ -164,6 +173,14 @@ func (a *Agent) gatherStats(cacheTimeMs uint16) *system.CombinedData {
}
// slog.Info("System data", "data", data, "cacheTimeMs", cacheTimeMs)
// Include static info for requests with longer intervals (e.g., 15 min)
// This reduces bandwidth by only sending static data occasionally
if cacheTimeMs >= StaticInfoIntervalMs {
staticInfoCopy := a.staticSystemInfo
data.StaticInfo = &staticInfoCopy
slog.Debug("Including static info", "cacheTimeMs", cacheTimeMs)
}
if a.dockerManager != nil {
if containerStats, err := a.dockerManager.getDockerStats(cacheTimeMs); err == nil {
data.Containers = containerStats
@@ -225,7 +242,11 @@ func (a *Agent) getFingerprint() string {
// if no fingerprint is found, generate one
fingerprint, err := host.HostID()
if err != nil || fingerprint == "" {
fingerprint = a.systemInfo.Hostname + a.systemInfo.CpuModel
cpuModel := ""
if len(a.staticSystemInfo.Cpus) > 0 {
cpuModel = a.staticSystemInfo.Cpus[0].Model
}
fingerprint = a.staticSystemInfo.Hostname + cpuModel
}
// hash fingerprint