* Add a new lint rule to the Makefile Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com> * Fix linter errors Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com> * Allow replacing the default apt mirror Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
		
			
				
	
	
		
			29 lines
		
	
	
		
			608 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			608 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// +build !solaris
 | 
						|
 | 
						|
package supervisor
 | 
						|
 | 
						|
import "github.com/cloudfoundry/gosigar"
 | 
						|
 | 
						|
// Machine holds the current machine cpu count and ram size
 | 
						|
type Machine struct {
 | 
						|
	Cpus   int
 | 
						|
	Memory int64
 | 
						|
}
 | 
						|
 | 
						|
// CollectMachineInformation returns information regarding the current
 | 
						|
// machine (e.g. CPU count, RAM amount)
 | 
						|
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
 | 
						|
}
 |