2015-12-03 19:49:56 +00:00
|
|
|
package containerd
|
|
|
|
|
|
|
|
import "github.com/cloudfoundry/gosigar"
|
|
|
|
|
|
|
|
type Machine struct {
|
2015-12-07 23:19:56 +00:00
|
|
|
ID string
|
2015-12-03 19:49:56 +00:00
|
|
|
Cpus int
|
|
|
|
Memory int64
|
|
|
|
}
|
|
|
|
|
2015-12-07 23:19:56 +00:00
|
|
|
func CollectMachineInformation(id string) (Machine, error) {
|
|
|
|
m := Machine{
|
|
|
|
ID: id,
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
m.Memory = int64(mem.Total)
|
|
|
|
return m, nil
|
|
|
|
}
|