优化监控上传

This commit is contained in:
奶爸
2019-12-11 21:50:49 +08:00
parent e6434e70f0
commit b521ba371c
5 changed files with 58 additions and 48 deletions

View File

@@ -11,11 +11,8 @@ const (
// State ..
type State struct {
CPU float64
MemTotal uint64
MemUsed uint64
SwapTotal uint64
SwapUsed uint64
DiskTotal uint64
DiskUsed uint64
NetInTransfer uint64
NetOutTransfer uint64
@@ -28,11 +25,8 @@ type State struct {
func (s *State) PB() *pb.State {
return &pb.State{
Cpu: s.CPU,
MemTotal: s.MemTotal,
MemUsed: s.MemUsed,
SwapTotal: s.SwapTotal,
SwapUsed: s.SwapUsed,
DiskTotal: s.DiskTotal,
DiskUsed: s.DiskUsed,
NetInTransfer: s.NetInTransfer,
NetOutTransfer: s.NetOutTransfer,
@@ -46,11 +40,8 @@ func (s *State) PB() *pb.State {
func PB2State(s *pb.State) State {
return State{
CPU: s.GetCpu(),
MemTotal: s.GetMemTotal(),
MemUsed: s.GetMemUsed(),
SwapTotal: s.GetSwapTotal(),
SwapUsed: s.GetSwapUsed(),
DiskTotal: s.GetDiskTotal(),
DiskUsed: s.GetDiskUsed(),
NetInTransfer: s.GetNetInTransfer(),
NetOutTransfer: s.GetNetOutTransfer(),
@@ -65,6 +56,9 @@ type Host struct {
Platform string
PlatformVersion string
CPU []string
MemTotal uint64
DiskTotal uint64
SwapTotal uint64
Arch string
Virtualization string
BootTime uint64
@@ -79,6 +73,9 @@ func (h *Host) PB() *pb.Host {
Platform: h.Platform,
PlatformVersion: h.PlatformVersion,
Cpu: h.CPU,
MemTotal: h.MemTotal,
DiskTotal: h.DiskTotal,
SwapTotal: h.SwapTotal,
Arch: h.Arch,
Virtualization: h.Virtualization,
BootTime: h.BootTime,
@@ -88,12 +85,16 @@ func (h *Host) PB() *pb.Host {
}
}
// PB2Host ...
func PB2Host(h *pb.Host) Host {
return Host{
Platform: h.GetPlatform(),
PlatformVersion: h.GetPlatformVersion(),
CPU: h.GetCpu(),
MemTotal: h.GetMemTotal(),
DiskTotal: h.GetDiskTotal(),
SwapTotal: h.GetSwapTotal(),
Arch: h.GetArch(),
Virtualization: h.GetVirtualization(),
BootTime: h.GetBootTime(),
@@ -102,3 +103,6 @@ func PB2Host(h *pb.Host) Host {
Version: h.GetVersion(),
}
}