Skip to content

Commit

Permalink
update debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
henrygd committed Oct 19, 2024
1 parent 7f01d1e commit b5c158d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions beszel/internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package agent

import (
"beszel"
"beszel/internal/entities/system"
"context"
"log/slog"
Expand Down Expand Up @@ -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)
if sysSensors, exists := os.LookupEnv("SYS_SENSORS"); exists {
slog.Info("SYS_SENSORS", "path", sysSensors)
Expand Down
9 changes: 5 additions & 4 deletions beszel/internal/agent/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ func (a *Agent) getSystemStats() system.Stats {

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

return systemStats
}
Expand Down

0 comments on commit b5c158d

Please sign in to comment.