This commit is contained in:
Mateusz Gruszczyński committed 2026-11-28 17:36:53 +01:00
1 parent 5b6d4a7903
commit 4d1087e357
160 files changed
+2407 -1933

No files matched your search

-3
View File
@@ -209,7 +209,6 @@ func (c *systemCollector) cpuPercent() *float64 {
previous := c.cpu
c.mu.Unlock()
if previous == nil {
// Initial sample takes time, but no collector mutex is held.
time.Sleep(200 * time.Millisecond)
next, ok := parseCPUStat(readTrimmed(c.procDir + "/stat"))
if !ok {
@@ -223,7 +222,6 @@ func (c *systemCollector) cpuPercent() *float64 {
if c.cpu != nil {
previous = c.cpu
}
// Concurrent collection must never roll the baseline backwards.
if c.cpu != nil && sample.total < c.cpu.total {
c.mu.Unlock()
return nil
@@ -269,7 +267,6 @@ func (c *systemCollector) collect(ctx context.Context, sock string) *systemInfo
info.NetworkRxBytes, info.NetworkTxBytes = ptr(rx), ptr(tx)
c.mu.Lock()
previous := c.net
// Do not let an older concurrent poll overwrite a newer sample.
if previous == nil || !now.Before(previous.at) {
c.net = &netSample{rx: rx, tx: tx, at: now}
}