machine.go 437 B

1234567891011121314151617181920212223242526
  1. // +build !solaris
  2. package supervisor
  3. import "github.com/cloudfoundry/gosigar"
  4. type Machine struct {
  5. Cpus int
  6. Memory int64
  7. }
  8. func CollectMachineInformation() (Machine, error) {
  9. m := Machine{}
  10. cpu := sigar.CpuList{}
  11. if err := cpu.Get(); err != nil {
  12. return m, err
  13. }
  14. m.Cpus = len(cpu.List)
  15. mem := sigar.Mem{}
  16. if err := mem.Get(); err != nil {
  17. return m, err
  18. }
  19. m.Memory = int64(mem.Total / 1024 / 1024)
  20. return m, nil
  21. }