mirror of
https://github.com/nezhahq/nezha.git
synced 2025-02-02 01:28:13 -05:00
format: json marshal
This commit is contained in:
parent
1e3c6b4a66
commit
45fcbd029f
@ -73,12 +73,14 @@ func getServerStat(c *gin.Context, withPublicNote bool) ([]byte, error) {
|
|||||||
var servers []model.StreamServer
|
var servers []model.StreamServer
|
||||||
for i := 0; i < len(serverList); i++ {
|
for i := 0; i < len(serverList); i++ {
|
||||||
server := serverList[i]
|
server := serverList[i]
|
||||||
|
host := *server.Host
|
||||||
|
host.IP = ""
|
||||||
servers = append(servers, model.StreamServer{
|
servers = append(servers, model.StreamServer{
|
||||||
ID: server.ID,
|
ID: server.ID,
|
||||||
Name: server.Name,
|
Name: server.Name,
|
||||||
PublicNote: utils.IfOr(withPublicNote, server.PublicNote, ""),
|
PublicNote: utils.IfOr(withPublicNote, server.PublicNote, ""),
|
||||||
DisplayIndex: server.DisplayIndex,
|
DisplayIndex: server.DisplayIndex,
|
||||||
Host: server.Host,
|
Host: &host,
|
||||||
State: server.State,
|
State: server.State,
|
||||||
LastActive: server.LastActive,
|
LastActive: server.LastActive,
|
||||||
})
|
})
|
||||||
|
@ -16,23 +16,23 @@ type SensorTemperature struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HostState struct {
|
type HostState struct {
|
||||||
CPU float64
|
CPU float64 `json:"cpu,omitempty"`
|
||||||
MemUsed uint64
|
MemUsed uint64 `json:"mem_used,omitempty"`
|
||||||
SwapUsed uint64
|
SwapUsed uint64 `json:"swap_used,omitempty"`
|
||||||
DiskUsed uint64
|
DiskUsed uint64 `json:"disk_used,omitempty"`
|
||||||
NetInTransfer uint64
|
NetInTransfer uint64 `json:"net_in_transfer,omitempty"`
|
||||||
NetOutTransfer uint64
|
NetOutTransfer uint64 `json:"net_out_transfer,omitempty"`
|
||||||
NetInSpeed uint64
|
NetInSpeed uint64 `json:"net_in_speed,omitempty"`
|
||||||
NetOutSpeed uint64
|
NetOutSpeed uint64 `json:"net_out_speed,omitempty"`
|
||||||
Uptime uint64
|
Uptime uint64 `json:"uptime,omitempty"`
|
||||||
Load1 float64
|
Load1 float64 `json:"load_1,omitempty"`
|
||||||
Load5 float64
|
Load5 float64 `json:"load_5,omitempty"`
|
||||||
Load15 float64
|
Load15 float64 `json:"load_15,omitempty"`
|
||||||
TcpConnCount uint64
|
TcpConnCount uint64 `json:"tcp_conn_count,omitempty"`
|
||||||
UdpConnCount uint64
|
UdpConnCount uint64 `json:"udp_conn_count,omitempty"`
|
||||||
ProcessCount uint64
|
ProcessCount uint64 `json:"process_count,omitempty"`
|
||||||
Temperatures []SensorTemperature
|
Temperatures []SensorTemperature `json:"temperatures,omitempty"`
|
||||||
GPU []float64
|
GPU []float64 `json:"gpu,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HostState) PB() *pb.State {
|
func (s *HostState) PB() *pb.State {
|
||||||
@ -96,19 +96,19 @@ func PB2State(s *pb.State) HostState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Host struct {
|
type Host struct {
|
||||||
Platform string
|
Platform string `json:"platform,omitempty"`
|
||||||
PlatformVersion string
|
PlatformVersion string `json:"platform_version,omitempty"`
|
||||||
CPU []string
|
CPU []string `json:"cpu,omitempty"`
|
||||||
MemTotal uint64
|
MemTotal uint64 `json:"mem_total,omitempty"`
|
||||||
DiskTotal uint64
|
DiskTotal uint64 `json:"disk_total,omitempty"`
|
||||||
SwapTotal uint64
|
SwapTotal uint64 `json:"swap_total,omitempty"`
|
||||||
Arch string
|
Arch string `json:"arch,omitempty"`
|
||||||
Virtualization string
|
Virtualization string `json:"virtualization,omitempty"`
|
||||||
BootTime uint64
|
BootTime uint64 `json:"boot_time,omitempty"`
|
||||||
IP string `json:"-"`
|
IP string `json:"ip,omitempty"`
|
||||||
CountryCode string
|
CountryCode string `json:"country_code,omitempty"`
|
||||||
Version string
|
Version string `json:"version,omitempty"`
|
||||||
GPU []string
|
GPU []string `json:"gpu,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Host) PB() *pb.Host {
|
func (h *Host) PB() *pb.Host {
|
||||||
|
Loading…
Reference in New Issue
Block a user