Documentation ¶
Overview ¶
cpu will examine /proc/stat to estimate how busy the CPU is. /proc/stat holds data of how much time the CPU has been idle/busy etc. since uptime.
client, err := cpu.NewClient() // .. handle error loads, err := client.GetLoads()
loads is a slice of how busy each CPU appears to be. loads[0] will almost certainly be the average over all cpus. All subsequent entries will be for each individual CPU.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client stores one read of the stat file. It is used to estimate CPU load.
func (*Client) GetLoads ¶
GetLoads() will perform a read of /proc/stat It will update the internal buffer with the information from said file. It returns how much time the cpus have been busy since the *last* call to get loads as a percentage. The order of the slice is the same as the order of the cpus in /proc/stat. The cpu total will almost certainly be in index 0, all subsequent entries are for the individual cores.