github.com/SimulatedSimian/cpuusage

Go library that monitors real time CPU usage (total and per-core) (linux only)


License
MIT
Install
go get github.com/SimulatedSimian/cpuusage

Documentation

cpuusage GoDoc

Go library that monitors real time CPU usage (total and per-core) (linux only)

Installation:

$ go get github.com/simulatedsimian/cpuusage

Example:

import "github.com/simulatedsimian/cpuusage"
   // display the cpu usage once per second
u := cpuusage.Usage{}

for {
  err := u.Measure()
  if err != nil {
    // handle error....
  }
  fmt.Printf("Overall %%: %d Per Core %%: %v\n", u.Overall, u.Cores)
  time.Sleep(1 * time.Second)
}