Merge branch 'V3.7' of https://github.com/goodrain/rainbond into V3.7

This commit is contained in:
barnettZQG 2018-10-18 12:19:13 +08:00
commit 6d225dc897
2 changed files with 3 additions and 1 deletions

View File

@ -153,6 +153,7 @@ type NodeSystemInfo struct {
Architecture string `json:"architecture"`
MemorySize uint64 `json:"memorySize"`
NumCPU int64 `json:"cpu_num"`
}
//Decode decode node info

View File

@ -45,6 +45,7 @@ func GetSystemInfo() (info client.NodeSystemInfo) {
}
info.OperatingSystem = runtime.GOOS
info.MemorySize, _ = getMemory()
info.NumCPU = int64(runtime.NumCPU())
return info
}
@ -72,7 +73,7 @@ func getMemory() (total uint64, free uint64) {
sysInfo := new(syscall.Sysinfo_t)
err := syscall.Sysinfo(sysInfo)
if err == nil {
return sysInfo.Totalram * uint64(syscall.Getpagesize()), sysInfo.Freeram * uint64(syscall.Getpagesize())
return uint64(sysInfo.Totalram) * uint64(sysInfo.Unit), sysInfo.Freeram * uint64(syscall.Getpagesize())
}
return 0, 0
}