environmentCaptureAgent/model/node.go

60 lines
2.0 KiB
Go
Raw Normal View History

2023-02-28 09:56:20 +08:00
package model
import "encoding/json"
// Node 节点信息
type Node struct {
2023-05-18 10:57:45 +08:00
NodeGuid string `json:"nodeGuid"`
2023-02-28 09:56:20 +08:00
NodeName string `json:"nodeName"`
2023-05-18 10:57:45 +08:00
NodeType int `json:"nodeType"`
2023-02-28 09:56:20 +08:00
Platform string `json:"platform,omitempty"`
PlatformVersion string `json:"platformVersion,omitempty"`
CPU []string `json:"cpu,omitempty"`
MemTotal uint64 `json:"memTotal,omitempty"`
DiskTotal uint64 `json:"diskTotal,omitempty"`
SwapTotal uint64 `json:"swapTotal,omitempty"`
Arch string `json:"arch,omitempty"`
Virtualization string `json:"virtualization,omitempty"`
BootTime uint64 `json:"bootTime,omitempty"`
IP string `json:"ip"`
CountryCode string `json:"countryCode,omitempty"`
Version string `json:"version,omitempty"`
}
func (n Node) ToByte() []byte {
data, err := json.Marshal(n)
if err != nil {
return []byte("")
}
return data
}
// NodeState 节点状态信息
type NodeState struct {
2023-05-18 10:57:45 +08:00
NodeGuid string `json:"nodeGuid"`
2023-02-28 09:56:20 +08:00
NodeName string `json:"nodeName"`
CPU float64 `json:"cpu,omitempty"`
MemUsed uint64 `json:"memUsed,omitempty"`
SwapUsed uint64 `json:"swapUsed,omitempty"`
DiskUsed uint64 `json:"diskUsed,omitempty"`
NetInTransfer uint64 `json:"netInTransfer,omitempty"`
NetOutTransfer uint64 `json:"netOutTransfer,omitempty"`
NetInSpeed uint64 `json:"netInSpeed,omitempty"`
NetOutSpeed uint64 `json:"netOutSpeed,omitempty"`
2023-03-24 08:51:04 +08:00
Uptime int64 `json:"uptime,omitempty"`
2023-02-28 09:56:20 +08:00
Load1 float64 `json:"load1,omitempty"`
Load5 float64 `json:"load5,omitempty"`
Load15 float64 `json:"load15,omitempty"`
TcpConnCount uint64 `json:"tcpConnCount,omitempty"`
UdpConnCount uint64 `json:"udpConnCount,omitempty"`
ProcessCount uint64 `json:"processCount,omitempty"`
}
func (ns NodeState) ToByte() []byte {
data, err := json.Marshal(ns)
if err != nil {
return []byte("")
}
return data
}