feat: Agent采集uptime, 后端持久化kernel/uptime/diskIO, 前端磁盘BPS+IOPS展示
- Agent: system.go 添加 readUptime(), SystemStat 携带 Uptime - Backend: Server 模型新增 Kernel 字段, ReceiveReport 持久化 kernel+uptime - Backend: /agent/latest 返回 kernel/uptime/port_info/disk_io_info/disk_total - Frontend: 磁盘监控改为 BPS+IOPS (4张卡片), 系统信息修复内核/运行时长/监听端口/磁盘容量 - 图表单位从 MB/s 改为 KB/s, 添加 formatBPS 工具函数
This commit is contained in:
1 parent
31c2e338a3
commit
5949ec5d0c
48 files changed
+2182
-956
No files matched your search
@@ -3,7 +3,6 @@ package models
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Server 服务器模型
|
||||
@@ -18,6 +17,7 @@ type Server struct {
|
||||
SSHKey string `gorm:"type:text" json:"-"`
|
||||
AuthType string `gorm:"size:32;default:password" json:"auth_type"` // password, key
|
||||
OS string `gorm:"size:64" json:"os"`
|
||||
Kernel string `gorm:"size:64" json:"kernel"`
|
||||
OSVersion string `gorm:"size:64" json:"os_version"`
|
||||
Arch string `gorm:"size:32" json:"arch"`
|
||||
CPU int `json:"cpu"`
|
||||
@@ -30,6 +30,7 @@ type Server struct {
|
||||
Uptime int64 `json:"uptime"` // seconds
|
||||
AgentVersion string `gorm:"size:32" json:"agent_version"`
|
||||
AgentStatus string `gorm:"size:32;default:offline" json:"agent_status"` // online, offline
|
||||
HasAuth bool `gorm:"-" json:"has_auth"` // 是否有认证凭据(密码或SSH密钥) — 不存DB,handler 计算后返回 // Logan.Li
|
||||
RegionID *uint `json:"region_id"`
|
||||
CloudID *uint `json:"cloud_id"`
|
||||
Tags string `gorm:"type:text" json:"tags"` // JSON
|
||||
@@ -37,7 +38,6 @@ type Server struct {
|
||||
LastCheckAt *time.Time `json:"last_check_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
// 关联
|
||||
Region *Region `json:"region,omitempty"`
|
||||
@@ -46,7 +46,7 @@ type Server struct {
|
||||
|
||||
// TableName 表名
|
||||
func (Server) TableName() string {
|
||||
return "servers"
|
||||
return "asset_servers"
|
||||
}
|
||||
|
||||
// Cloud 云平台模型
|
||||
@@ -60,12 +60,11 @@ type Cloud struct {
|
||||
Description string `gorm:"size:500" json:"description"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (Cloud) TableName() string {
|
||||
return "clouds"
|
||||
return "asset_clouds"
|
||||
}
|
||||
|
||||
// CloudAccount 云账号模型
|
||||
@@ -82,12 +81,11 @@ type CloudAccount struct {
|
||||
LastSyncAt *time.Time `json:"last_sync_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (CloudAccount) TableName() string {
|
||||
return "cloud_accounts"
|
||||
return "asset_cloud_accounts"
|
||||
}
|
||||
|
||||
// Region 区域模型
|
||||
@@ -102,12 +100,11 @@ type Region struct {
|
||||
VPCCount int `gorm:"default:0" json:"vpc_count"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (Region) TableName() string {
|
||||
return "regions"
|
||||
return "asset_regions"
|
||||
}
|
||||
|
||||
// Domain 域名模型
|
||||
@@ -123,12 +120,11 @@ type Domain struct {
|
||||
SSLExpireDate *time.Time `json:"ssl_expire_date"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (Domain) TableName() string {
|
||||
return "domains"
|
||||
return "asset_domains"
|
||||
}
|
||||
|
||||
// CreateServerRequest 创建服务器请求
|
||||
@@ -188,9 +184,10 @@ type BatchServerItem struct {
|
||||
|
||||
// BatchCreateServerRequest 批量导入服务器请求 // Logan.Li
|
||||
type BatchCreateServerRequest struct {
|
||||
Servers []BatchServerItem `json:"servers"`
|
||||
RegionID *uint `json:"region_id"`
|
||||
AuthType string `json:"auth_type"`
|
||||
Servers []BatchServerItem `json:"servers"`
|
||||
RegionID *uint `json:"region_id"`
|
||||
AuthType string `json:"auth_type"`
|
||||
CredentialID *uint `json:"credential_id"` // 凭据ID,非空则解密后写入每台服务器
|
||||
}
|
||||
|
||||
// BatchCreateResult 批量导入结果 // Logan.Li
|
||||
|
||||
Reference in new issue
Block a user