@@ -12,37 +12,49 @@ import (
1212 "gorm.io/gorm"
1313)
1414
15+ // State 服务器状态
16+ type State struct {
17+ CPU float64 `json:"cpu"`
18+ MemUsed uint64 `json:"mem_used"`
19+ SwapUsed uint64 `json:"swap_used"`
20+ DiskUsed uint64 `json:"disk_used"`
21+ NetInTransfer uint64 `json:"net_in_transfer"`
22+ NetOutTransfer uint64 `json:"net_out_transfer"`
23+ NetInSpeed uint64 `json:"net_in_speed"`
24+ NetOutSpeed uint64 `json:"net_out_speed"`
25+ Uptime uint64 `json:"uptime"`
26+ Load1 float64 `json:"load1"`
27+ Load5 float64 `json:"load5"`
28+ Load15 float64 `json:"load15"`
29+ TcpConnCount int64 `json:"tcp_conn_count"`
30+ UdpConnCount int64 `json:"udp_conn_count"`
31+ ProcessCount int64 `json:"process_count"`
32+ Temperatures []float64 `json:"temperatures"`
33+ }
34+
1535type Server struct {
16- ID uint64 `json:"id" gorm:"primaryKey"`
17- Name string `json:"name"`
18- Secret string `json:"secret"`
19- Tag string `json:"tag"`
20- DisplayIndex int `json:"display_index"`
21- Host * Host `json:"host" gorm:"-"`
22- State * State `json:"state" gorm:"-"`
23- LastActive time.Time `json:"last_active"`
24- Note string `json:"note"`
25- PublicNote string `json:"public_note"`
26- EnableDDNS bool `json:"enable_ddns"`
27- DDNSProfilesRaw string `json:"ddns_profiles_raw"`
28- HideForGuest bool `json:"hide_for_guest"`
36+ ID uint64 `json:"id" gorm:"primaryKey"`
37+ Name string `json:"name"`
38+ Secret string `json:"secret"`
39+ Tag string `json:"tag"` // 分组名
40+ DisplayIndex int `json:"display_index"` // 展示排序,越大越靠前
41+ Host * Host `json:"host" gorm:"-"`
42+ State * State `json:"state" gorm:"-"`
43+ LastActive time.Time `json:"last_active"`
44+ Note string `json:"note"` // 管理员可见备注
45+ PublicNote string `json:"public_note,omitempty"` // 公开备注
46+ EnableDDNS bool `json:"enable_ddns"` // 启用DDNS
47+ DDNSProfilesRaw string `json:"ddns_profiles_raw" gorm:"default:'[]'"`
48+ HideForGuest bool `json:"hide_for_guest"`
49+ DDNSProfiles []uint64 `gorm:"-" json:"-"` // DDNS配置
50+ LastStateBeforeOffline * HostState `gorm:"-" json:"-"` // 离线前最后一次状态
51+ IsOnline bool `gorm:"-" json:"is_online"` // 是否在线
52+
2953 // 累计流量统计
3054 CumulativeNetInTransfer uint64 `json:"cumulative_net_in_transfer" gorm:"default:0"`
3155 CumulativeNetOutTransfer uint64 `json:"cumulative_net_out_transfer" gorm:"default:0"`
3256 LastTrafficReset time.Time `json:"last_traffic_reset"`
3357
34- Tag string // 分组名
35- Note string `json:"-"` // 管理员可见备注
36- PublicNote string `json:"PublicNote,omitempty"` // 公开备注
37- DisplayIndex int // 展示排序,越大越靠前
38- EnableDDNS bool // 启用DDNS
39- DDNSProfiles []uint64 `gorm:"-" json:"-"` // DDNS配置
40-
41- DDNSProfilesRaw string `gorm:"default:'[]';column:ddns_profiles_raw" json:"-"`
42-
43- LastStateBeforeOffline * HostState `gorm:"-" json:"-"` // 离线前最后一次状态
44- IsOnline bool `gorm:"-" json:"is_online"` // 是否在线
45-
4658 // 持久化保存的最后状态
4759 LastStateJSON string `gorm:"type:text" json:"-"` // 最后一次状态的JSON格式
4860 LastOnline time.Time // 最后一次在线时间
0 commit comments