devices

package
v3.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2020 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCPU

func RegisterCPU(f func(map[string]int, time.Duration, bool) map[string]error)

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 RegisterTemp

func RegisterTemp(update func(map[string]int) map[string]error)

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

func UpdateCPU(cpus map[string]int, interval time.Duration, logical bool)

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)

func UpdateTemps

func UpdateTemps(temps map[string]int)

Types

type MemoryInfo

type MemoryInfo struct {
	Total       uint64
	Used        uint64
	UsedPercent float64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL