2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-12-03 19:49:56 +00:00
|
|
|
|
|
|
|
import "github.com/cloudfoundry/gosigar"
|
|
|
|
|
|
|
|
type Machine struct {
|
|
|
|
Cpus int
|
|
|
|
Memory int64
|
|
|
|
}
|
|
|
|
|
2016-01-06 21:32:46 +00:00
|
|
|
func CollectMachineInformation() (Machine, error) {
|
|
|
|
m := Machine{}
|
2015-12-03 19:49:56 +00:00
|
|
|
cpu := sigar.CpuList{}
|
|
|
|
if err := cpu.Get(); err != nil {
|
|
|
|
return m, err
|
|
|
|
}
|
|
|
|
m.Cpus = len(cpu.List)
|
|
|
|
mem := sigar.Mem{}
|
|
|
|
if err := mem.Get(); err != nil {
|
|
|
|
return m, err
|
|
|
|
}
|
2016-02-11 23:55:19 +00:00
|
|
|
m.Memory = int64(mem.Total / 1024 / 1024)
|
2015-12-03 19:49:56 +00:00
|
|
|
return m, nil
|
|
|
|
}
|