mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
agent: add lock for gatherStats
This commit is contained in:
@@ -8,11 +8,13 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/common"
|
||||
)
|
||||
|
||||
type Agent struct {
|
||||
sync.Mutex // Used to lock agent while collecting data
|
||||
debug bool // true if LOG_LEVEL is set to debug
|
||||
zfs bool // true if system has arcstats
|
||||
memCalc string // Memory calculation formula
|
||||
@@ -99,6 +101,8 @@ func GetEnv(key string) (value string, exists bool) {
|
||||
}
|
||||
|
||||
func (a *Agent) gatherStats() system.CombinedData {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
slog.Debug("Getting stats")
|
||||
systemData := system.CombinedData{
|
||||
Stats: a.getSystemStats(),
|
||||
|
Reference in New Issue
Block a user