update debug logs

This commit is contained in:
Henry Dollman
2024-10-19 18:12:25 -04:00
parent 7f01d1ec7e
commit b5c158d1b3
2 changed files with 8 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
package agent package agent
import ( import (
"beszel"
"beszel/internal/entities/system" "beszel/internal/entities/system"
"context" "context"
"log/slog" "log/slog"
@@ -47,6 +48,8 @@ func (a *Agent) Run(pubKey []byte, addr string) {
} }
} }
slog.Debug(beszel.Version)
// Set sensors context (allows overriding sys location for sensors) // Set sensors context (allows overriding sys location for sensors)
if sysSensors, exists := os.LookupEnv("SYS_SENSORS"); exists { if sysSensors, exists := os.LookupEnv("SYS_SENSORS"); exists {
slog.Info("SYS_SENSORS", "path", sysSensors) slog.Info("SYS_SENSORS", "path", sysSensors)

View File

@@ -173,12 +173,12 @@ func (a *Agent) getSystemStats() system.Stats {
// temperatures // temperatures
temps, err := sensors.TemperaturesWithContext(a.sensorsContext) temps, err := sensors.TemperaturesWithContext(a.sensorsContext)
if err != nil && a.debug { if err != nil {
err.(*sensors.Warnings).Verbose = true // err.(*sensors.Warnings).Verbose = true
slog.Debug("Sensor error", "errs", err) slog.Debug("Sensor error", "err", err)
} }
slog.Debug("Temperature", "sensors", temps)
if len(temps) > 0 { if len(temps) > 0 {
slog.Debug("Temperatures", "data", temps)
systemStats.Temperatures = make(map[string]float64, len(temps)) systemStats.Temperatures = make(map[string]float64, len(temps))
for i, sensor := range temps { for i, sensor := range temps {
// skip if temperature is 0 // skip if temperature is 0
@@ -209,6 +209,7 @@ func (a *Agent) getSystemStats() system.Stats {
a.systemInfo.DiskPct = systemStats.DiskPct a.systemInfo.DiskPct = systemStats.DiskPct
a.systemInfo.Uptime, _ = host.Uptime() a.systemInfo.Uptime, _ = host.Uptime()
a.systemInfo.Bandwidth = twoDecimals(systemStats.NetworkSent + systemStats.NetworkRecv) a.systemInfo.Bandwidth = twoDecimals(systemStats.NetworkSent + systemStats.NetworkRecv)
slog.Debug("sysinfo", "data", a.systemInfo)
return systemStats return systemStats
} }