xmtop/devices/mem_swap_other.go
Sean E. Russell 7a89225d72 Abstracts CPU & mem devices.
Finishes device refactoring: temps

Refactoring to allow updating maps. Simpler, and optimizable.
2020-02-28 07:06:51 -06:00

24 lines
423 B
Go

// +build !freebsd
package devices
import (
psMem "github.com/shirou/gopsutil/mem"
)
func init() {
mf := func(mems map[string]MemoryInfo) map[string]error {
memory, err := psMem.SwapMemory()
if err != nil {
return map[string]error{"Swap": err}
}
mems["Swap"] = MemoryInfo{
Total: memory.Total,
Used: memory.Used,
UsedPercent: memory.UsedPercent,
}
return nil
}
RegisterMem(mf)
}