Query the system status https://maze.io/system.v0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

load_linux.go 324B

123456789101112
  1. package system
  2. import "syscall"
  3. func loadAverage() (float32, float32, float32) {
  4. sysinfo := syscall.Sysinfo_t{}
  5. if err := syscall.Sysinfo(&sysinfo); err != nil {
  6. panic(err)
  7. }
  8. const frac = float32(1 << 16)
  9. return float32(sysinfo.Loads[0]) / frac, float32(sysinfo.Loads[1]) / frac, float32(sysinfo.Loads[2]) / frac
  10. }