2016-05-19 17:12:50 +00:00
|
|
|
// +build !solaris
|
|
|
|
|
2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-12-03 19:49:56 +00:00
|
|
|
|
2016-04-26 20:29:35 +00:00
|
|
|
import "github.com/cloudfoundry/gosigar"
|
|
|
|
|
2015-12-03 19:49:56 +00:00
|
|
|
type Machine struct {
|
|
|
|
Cpus int
|
|
|
|
Memory int64
|
|
|
|
}
|
2016-04-26 20:29:35 +00:00
|
|
|
|
|
|
|
func CollectMachineInformation() (Machine, error) {
|
|
|
|
m := Machine{}
|
|
|
|
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
|
|
|
|
}
|
|
|
|
m.Memory = int64(mem.Total / 1024 / 1024)
|
|
|
|
return m, nil
|
|
|
|
}
|