2016-05-19 10:12:50 -07:00
|
|
|
// +build !solaris
|
|
|
|
|
2015-12-17 16:07:04 -08:00
|
|
|
package supervisor
|
2015-12-03 11:49:56 -08:00
|
|
|
|
2016-04-26 13:29:35 -07:00
|
|
|
import "github.com/cloudfoundry/gosigar"
|
|
|
|
|
2016-06-03 15:00:49 -07:00
|
|
|
// Machine holds the current machine cpu count and ram size
|
2015-12-03 11:49:56 -08:00
|
|
|
type Machine struct {
|
|
|
|
Cpus int
|
|
|
|
Memory int64
|
|
|
|
}
|
2016-04-26 13:29:35 -07:00
|
|
|
|
2016-06-03 15:00:49 -07:00
|
|
|
// CollectMachineInformation returns information regarding the current
|
|
|
|
// machine (e.g. CPU count, RAM amount)
|
2016-04-26 13:29:35 -07: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
|
|
|
|
}
|