mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 21:20:06 +00:00
gRPC 上报系统信息
This commit is contained in:
57
model/monitor.go
Normal file
57
model/monitor.go
Normal file
@@ -0,0 +1,57 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user