Read swap statistics only if swap stats enabled

This commit is contained in:
eleksir
2026-03-31 00:29:09 +03:00
parent deeb0dfbf0
commit 40213ba5c3

View File

@@ -38,6 +38,7 @@ func (c *MyConfig) UpdateMemStats() {
continue
}
if c.Mem.ShowSwap {
sw, err := mem.SwapMemory()
if err != nil {
@@ -47,7 +48,6 @@ func (c *MyConfig) UpdateMemStats() {
continue
}
if c.Mem.ShowSwap {
if c.Values.Memory.Usedpct != uint64(v.UsedPercent) || c.Values.Memory.Shared != v.Shared/1024/1024 || c.Values.Memory.Swap != sw.Used/1024/1024 {
c.Values.Memory.Usedpct = uint64(v.UsedPercent)
c.Values.Memory.Shared = v.Shared / 1024 / 1024