From f1e5797c76a234b1c59a31c815f07edfbee0b0e9 Mon Sep 17 00:00:00 2001 From: Aditya Raj Singh Date: Sat, 22 Aug 2026 03:00:19 +0530 Subject: [PATCH] fix(agent): round load average to two decimals (#2245) Every other metric in getSystemStats is stored through utils.TwoDecimals. The load averages were assigned straight from gopsutil, so whatever the platform reported was recorded verbatim. On Linux that goes unnoticed because /proc/loadavg is already two decimal places. Everywhere else it is not. macOS and BSD divide a fixed point value by fscale and produce numbers like 2.55322265625, and the Windows implementation synthesises the average as a decaying EWMA over the processor queue length counter, so an idle machine reports values like 1.3667392689044936e-73 instead of 0. The hub already treats two decimals as the canonical precision for this field, since records.go rounds the load average when it averages records. That left the raw agent records as the only place carrying full precision. --- agent/system.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/system.go b/agent/system.go index 33831580f..fa5575947 100644 --- a/agent/system.go +++ b/agent/system.go @@ -171,9 +171,9 @@ func (a *Agent) getSystemStats(cacheTimeMs uint16) system.Stats { // load average if avgstat, err := load.Avg(); err == nil { - systemStats.LoadAvg[0] = avgstat.Load1 - systemStats.LoadAvg[1] = avgstat.Load5 - systemStats.LoadAvg[2] = avgstat.Load15 + systemStats.LoadAvg[0] = utils.TwoDecimals(avgstat.Load1) + systemStats.LoadAvg[1] = utils.TwoDecimals(avgstat.Load5) + systemStats.LoadAvg[2] = utils.TwoDecimals(avgstat.Load15) slog.Debug("Load average", "5m", avgstat.Load5, "15m", avgstat.Load15) } else { slog.Error("Error getting load average", "err", err)