Skip to content

Instantly share code, notes, and snippets.

@guaychou
Last active May 17, 2020 09:07
Show Gist options
  • Save guaychou/76efbf70f176c3c7ec48df8e267f5489 to your computer and use it in GitHub Desktop.
Save guaychou/76efbf70f176c3c7ec48df8e267f5489 to your computer and use it in GitHub Desktop.
package main
import (
"time"
"github.com/shirou/gopsutil/cpu"
)
func getCpuUsage()int{
percent,err:=cpu.Percent(time.Second,false)
if err!=nil{
log.Fatal(err)
}
return int(math.Ceil(percent[0]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment