Documentation ¶
Index ¶
- func RegisterCPU(f func(map[string]int, time.Duration, bool) map[string]error)
- func RegisterMem(f func(map[string]MemoryInfo) map[string]error)
- func RegisterShutdown(f func() error)
- func RegisterTemp(update func(map[string]int) map[string]error)
- func Shutdown()
- func UpdateCPU(cpus map[string]int, interval time.Duration, logical bool)
- func UpdateMem(mem map[string]MemoryInfo)
- func UpdateTemps(temps map[string]int)
- type MemoryInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCPU ¶
RegisterCPU adds a new CPU device to the CPU widget. labels returns the names of the devices; they should be as short as possible, and the indexes of the returned slice should align with the values returned by the percents function. The percents function should return the percent CPU usage of the device(s), sliced over the time duration supplied. If the bool argument to percents is true, it is expected that the return slice
labels may be called once and the value cached. This means the number of cores should not change dynamically.
func RegisterMem ¶
func RegisterMem(f func(map[string]MemoryInfo) map[string]error)
func RegisterShutdown ¶
func RegisterShutdown(f func() error)
RegisterShutdown stores a function to be called by gotop on exit, allowing extensions to properly release resources. Extensions should register a shutdown function IFF the extension is using resources that need to be released. The returned error will be logged, but no other action will be taken.
func Shutdown ¶
func Shutdown()
Shutdown will be called by the `main()` function if gotop is exited cleanly. It will call all of the registered shutdown functions of devices, logging all errors but otherwise not responding to them.
func UpdateCPU ¶
CPUPercent calculates the percentage of cpu used either per CPU or combined. Returns one value per cpu, or a single value if percpu is set to false.
func UpdateMem ¶
func UpdateMem(mem map[string]MemoryInfo)