60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package model
|
|
|
|
import "encoding/json"
|
|
|
|
// Node 节点信息
|
|
type Node struct {
|
|
NodeGuid string `json:"nodeGuid"`
|
|
NodeName string `json:"nodeName"`
|
|
NodeType int `json:"nodeType"`
|
|
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 {
|
|
NodeGuid string `json:"nodeGuid"`
|
|
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"`
|
|
Uptime int64 `json:"uptime,omitempty"`
|
|
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
|
|
}
|