mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 18:58:02 +08:00
[FIX] fix get node system info bug
This commit is contained in:
parent
a217cf54c2
commit
9a5bd730d8
@ -58,6 +58,7 @@ type etcdClusterClient struct {
|
||||
|
||||
func (e *etcdClusterClient) UpdateStatus(n *HostNode) error {
|
||||
n.UpTime = time.Now()
|
||||
n.Alived = true
|
||||
if err := e.Update(n); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ type NodeSystemInfo struct {
|
||||
// The Architecture reported by the node
|
||||
Architecture string `json:"architecture"`
|
||||
|
||||
MemorySize uint32 `json:"memorySize"`
|
||||
MemorySize uint64 `json:"memorySize"`
|
||||
}
|
||||
|
||||
//Decode decode node info
|
||||
|
@ -22,9 +22,9 @@ package info
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"exec"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
@ -61,18 +61,18 @@ func readOS() map[string]string {
|
||||
if err != nil {
|
||||
return info
|
||||
}
|
||||
lines := strings.Split(line, "=")
|
||||
lines := strings.Split(string(line), "=")
|
||||
if len(lines) >= 2 {
|
||||
info[lines[0]] = lines[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getMemory() (total uint32, free uint32) {
|
||||
func getMemory() (total uint64, free uint64) {
|
||||
sysInfo := new(syscall.Sysinfo_t)
|
||||
err := syscall.Sysinfo(sysInfo)
|
||||
if err == nil {
|
||||
return sysInfo.Totalram * uint32(syscall.Getpagesize()), sysInfo.Freeram * uint32(syscall.Getpagesize())
|
||||
return sysInfo.Totalram * uint64(syscall.Getpagesize()), sysInfo.Freeram * uint64(syscall.Getpagesize())
|
||||
}
|
||||
return 0, 0
|
||||
}
|
||||
|
@ -141,6 +141,7 @@ func (n *NodeManager) heartbeat() {
|
||||
if err := n.cluster.UpdateStatus(&n.HostNode); err != nil {
|
||||
logrus.Errorf("update node status error %s", err.Error())
|
||||
}
|
||||
logrus.Info("update node status success")
|
||||
return nil
|
||||
}, time.Second*time.Duration(n.cfg.TTL))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user