Last active
May 17, 2020 09:07
-
-
Save guaychou/76efbf70f176c3c7ec48df8e267f5489 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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