nezha/model/monitor.go

58 lines
1.1 KiB
Go
Raw Normal View History

2019-12-07 05:14:40 -05:00
package model
import pb "github.com/p14yground/nezha/proto"
// State ..
type State struct {
CPU float64
MEMTotal uint64
MEMUsed uint64
SwapTotal uint64
SwapUsed uint64
DiskTotal uint64
DiskUsed uint64
NetIn uint64
NetOut uint64
}
// PB ..
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,
NetIn: s.NetIn,
NetOut: s.NetOut,
}
}
// Host ..
type Host struct {
Platform string
PlatformVersion string
CPU []string
Arch string
Virtualization string
Uptime string
BootTime string
Version string
}
// PB ..
func (h *Host) PB() *pb.Host {
return &pb.Host{
Platform: h.Platform,
PlatformVersion: h.PlatformVersion,
Cpu: h.CPU,
Arch: h.Arch,
Virtualization: h.Virtualization,
Uptime: h.Uptime,
BootTime: h.BootTime,
Version: h.Version,
}
}