Documentation
¶
Index ¶
- func DropOldTables(db *gorm.DB) error
- func Migrate(db *gorm.DB, client *vmclient.VMClient) error
- type AggregatedCPUMetricModel
- type AggregatedDiskIOMetricModel
- type AggregatedDiskMetricModel
- type AggregatedGPUMetricModel
- type AggregatedMemoryMetricModel
- type AggregatedMonitorMetricModel
- type AggregatedNetworkConnectionMetricModel
- type AggregatedNetworkMetricModel
- type AggregatedTemperatureMetricModel
- type AggregationProgress
- type CPUMetric
- type DiskIOMetric
- type DiskMetric
- type GPUMetric
- type HostMetric
- type MemoryMetric
- type MonitorMetric
- type NetworkConnectionMetric
- type NetworkMetric
- type TemperatureMetric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AggregatedCPUMetricModel ¶
type AggregatedCPUMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_cpuagg_agent_bucket,priority:1;uniqueIndex:ux_cpuagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_cpuagg_agent_bucket,priority:2;uniqueIndex:ux_cpuagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_cpuagg_agent_bucket,priority:3;uniqueIndex:ux_cpuagg_bucket,priority:3" json:"bucketStart"` // 毫秒
MaxUsage float64 `json:"maxUsage"`
LogicalCores int `json:"logicalCores"`
}
AggregatedCPUMetricModel CPU聚合表
func (AggregatedCPUMetricModel) TableName ¶
func (AggregatedCPUMetricModel) TableName() string
type AggregatedDiskIOMetricModel ¶
type AggregatedDiskIOMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_diskioagg_agent_bucket,priority:1;uniqueIndex:ux_diskioagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_diskioagg_agent_bucket,priority:2;uniqueIndex:ux_diskioagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_diskioagg_agent_bucket,priority:3;uniqueIndex:ux_diskioagg_bucket,priority:3" json:"bucketStart"` // 毫秒
MaxReadBytesRate uint64 `json:"maxReadBytesRate"`
MaxWriteBytesRate uint64 `json:"maxWriteBytesRate"`
MaxIopsInProgress uint64 `json:"maxIopsInProgress"`
}
AggregatedDiskIOMetricModel 磁盘IO聚合表(汇总所有磁盘)
func (AggregatedDiskIOMetricModel) TableName ¶
func (AggregatedDiskIOMetricModel) TableName() string
type AggregatedDiskMetricModel ¶
type AggregatedDiskMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_diskagg_agent_bucket_mp,priority:1;uniqueIndex:ux_diskagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_diskagg_agent_bucket_mp,priority:2;uniqueIndex:ux_diskagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_diskagg_agent_bucket_mp,priority:3;uniqueIndex:ux_diskagg_bucket,priority:3" json:"bucketStart"` // 毫秒
MountPoint string `gorm:"index:idx_diskagg_agent_bucket_mp,priority:4;uniqueIndex:ux_diskagg_bucket,priority:4" json:"mountPoint"`
MaxUsage float64 `json:"maxUsage"`
Total uint64 `json:"total"`
}
AggregatedDiskMetricModel 磁盘聚合表
func (AggregatedDiskMetricModel) TableName ¶
func (AggregatedDiskMetricModel) TableName() string
type AggregatedGPUMetricModel ¶
type AggregatedGPUMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_gpuagg_agent_bucket_idx,priority:1;uniqueIndex:ux_gpuagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_gpuagg_agent_bucket_idx,priority:2;uniqueIndex:ux_gpuagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_gpuagg_agent_bucket_idx,priority:3;uniqueIndex:ux_gpuagg_bucket,priority:3" json:"bucketStart"` // 毫秒
Index int `gorm:"index:idx_gpuagg_agent_bucket_idx,priority:4;uniqueIndex:ux_gpuagg_bucket,priority:4" json:"index"`
Name string `json:"name"`
MaxUtilization float64 `json:"maxUtilization"`
MaxMemoryUsed uint64 `json:"maxMemoryUsed"`
MaxTemperature float64 `json:"maxTemperature"`
MaxPowerDraw float64 `json:"maxPowerDraw"`
MemoryTotal uint64 `json:"memoryTotal"`
}
AggregatedGPUMetricModel GPU聚合表
func (AggregatedGPUMetricModel) TableName ¶
func (AggregatedGPUMetricModel) TableName() string
type AggregatedMemoryMetricModel ¶
type AggregatedMemoryMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_memagg_agent_bucket,priority:1;uniqueIndex:ux_memagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_memagg_agent_bucket,priority:2;uniqueIndex:ux_memagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_memagg_agent_bucket,priority:3;uniqueIndex:ux_memagg_bucket,priority:3" json:"bucketStart"` // 毫秒
MaxUsage float64 `json:"maxUsage"`
Total uint64 `json:"total"`
}
AggregatedMemoryMetricModel 内存聚合表
func (AggregatedMemoryMetricModel) TableName ¶
func (AggregatedMemoryMetricModel) TableName() string
type AggregatedMonitorMetricModel ¶
type AggregatedMonitorMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
MonitorID string `gorm:"index:idx_monitoragg_monitor_agent_bucket,priority:1;uniqueIndex:ux_monitoragg_bucket,priority:1" json:"monitorId"`
AgentID string `gorm:"index:idx_monitoragg_monitor_agent_bucket,priority:2;uniqueIndex:ux_monitoragg_bucket,priority:2" json:"agentId"`
BucketSeconds int `gorm:"index:idx_monitoragg_monitor_agent_bucket,priority:3;uniqueIndex:ux_monitoragg_bucket,priority:3" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_monitoragg_monitor_agent_bucket,priority:4;uniqueIndex:ux_monitoragg_bucket,priority:4" json:"bucketStart"` // 毫秒
AvgResponse float64 `json:"avgResponse"` // 平均响应时间(ms)
MaxResponse int64 `json:"maxResponse"` // 最大响应时间(ms)
MinResponse int64 `json:"minResponse"` // 最小响应时间(ms)
SuccessCount int64 `json:"successCount"` // 成功次数
TotalCount int64 `json:"totalCount"` // 总次数
SuccessRate float64 `json:"successRate"` // 成功率(百分比)
LastStatus string `json:"lastStatus"` // 最后状态
LastError string `json:"lastError"` // 最后错误信息
}
AggregatedMonitorMetricModel 监控指标聚合表
func (AggregatedMonitorMetricModel) TableName ¶
func (AggregatedMonitorMetricModel) TableName() string
type AggregatedNetworkConnectionMetricModel ¶
type AggregatedNetworkConnectionMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_netconnagg_agent_bucket,priority:1;uniqueIndex:ux_netconnagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_netconnagg_agent_bucket,priority:2;uniqueIndex:ux_netconnagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_netconnagg_agent_bucket,priority:3;uniqueIndex:ux_netconnagg_bucket,priority:3" json:"bucketStart"` // 毫秒
MaxEstablished uint32 `json:"maxEstablished"`
MaxSynSent uint32 `json:"maxSynSent"`
MaxSynRecv uint32 `json:"maxSynRecv"`
MaxFinWait1 uint32 `json:"maxFinWait1"`
MaxFinWait2 uint32 `json:"maxFinWait2"`
MaxTimeWait uint32 `json:"maxTimeWait"`
MaxClose uint32 `json:"maxClose"`
MaxCloseWait uint32 `json:"maxCloseWait"`
MaxLastAck uint32 `json:"maxLastAck"`
MaxListen uint32 `json:"maxListen"`
MaxClosing uint32 `json:"maxClosing"`
MaxTotal uint32 `json:"maxTotal"`
}
AggregatedNetworkConnectionMetricModel 网络连接聚合表
func (AggregatedNetworkConnectionMetricModel) TableName ¶
func (AggregatedNetworkConnectionMetricModel) TableName() string
type AggregatedNetworkMetricModel ¶
type AggregatedNetworkMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_netagg_agent_bucket_iface,priority:1;uniqueIndex:ux_netagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_netagg_agent_bucket_iface,priority:2;uniqueIndex:ux_netagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_netagg_agent_bucket_iface,priority:3;uniqueIndex:ux_netagg_bucket,priority:3" json:"bucketStart"` // 毫秒
Interface string `gorm:"index:idx_netagg_agent_bucket_iface,priority:4;uniqueIndex:ux_netagg_bucket,priority:4" json:"interface"`
MaxSentRate float64 `json:"maxSentRate"`
MaxRecvRate float64 `json:"maxRecvRate"`
}
AggregatedNetworkMetricModel 网络聚合表(按网卡分组)
func (AggregatedNetworkMetricModel) TableName ¶
func (AggregatedNetworkMetricModel) TableName() string
type AggregatedTemperatureMetricModel ¶
type AggregatedTemperatureMetricModel struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_tempagg_agent_bucket_sensor,priority:1;uniqueIndex:ux_tempagg_bucket,priority:1" json:"agentId"`
BucketSeconds int `gorm:"index:idx_tempagg_agent_bucket_sensor,priority:2;uniqueIndex:ux_tempagg_bucket,priority:2" json:"bucketSeconds"`
BucketStart int64 `gorm:"index:idx_tempagg_agent_bucket_sensor,priority:3;uniqueIndex:ux_tempagg_bucket,priority:3" json:"bucketStart"` // 毫秒
SensorKey string `gorm:"index:idx_tempagg_agent_bucket_sensor,priority:4;uniqueIndex:ux_tempagg_bucket,priority:4" json:"sensorKey"`
SensorLabel string `json:"sensorLabel"`
MaxTemperature float64 `json:"maxTemperature"`
}
AggregatedTemperatureMetricModel 温度聚合表
func (AggregatedTemperatureMetricModel) TableName ¶
func (AggregatedTemperatureMetricModel) TableName() string
type AggregationProgress ¶
type AggregationProgress struct {
MetricType string `gorm:"primaryKey"` // cpu/memory/disk/network
BucketSeconds int `gorm:"primaryKey"`
LastBucket int64 `json:"lastBucket"` // 已完成的最后 bucket 起始时间(毫秒)
UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli"`
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli"`
}
AggregationProgress 聚合进度记录
func (AggregationProgress) TableName ¶
func (AggregationProgress) TableName() string
type CPUMetric ¶
type CPUMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_cpu_agent_ts,priority:1" json:"agentId"` // 探针ID
UsagePercent float64 `json:"usagePercent"` // CPU使用率
LogicalCores int `json:"logicalCores"` // 逻辑核心数
PhysicalCores int `json:"physicalCores"` // 物理核心数
ModelName string `json:"modelName"` // CPU型号
Timestamp int64 `gorm:"index:idx_cpu_agent_ts,priority:2;index:idx_cpu_ts" json:"timestamp"` // 时间戳(毫秒)
}
CPUMetric CPU指标
type DiskIOMetric ¶
type DiskIOMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_diskio_agent_ts,priority:1" json:"agentId"` // 探针ID
Device string `json:"device"` // 设备名称
ReadCount uint64 `json:"readCount"` // 读取次数
WriteCount uint64 `json:"writeCount"` // 写入次数
ReadBytes uint64 `json:"readBytes"` // 读取字节数
WriteBytes uint64 `json:"writeBytes"` // 写入字节数
ReadBytesRate uint64 `json:"readBytesRate"` // 读取速率(字节/秒)
WriteBytesRate uint64 `json:"writeBytesRate"` // 写入速率(字节/秒)
ReadTime uint64 `json:"readTime"` // 读取时间(毫秒)
WriteTime uint64 `json:"writeTime"` // 写入时间(毫秒)
IoTime uint64 `json:"ioTime"` // IO时间(毫秒)
IopsInProgress uint64 `json:"iopsInProgress"` // 正在进行的IO操作数
Timestamp int64 `gorm:"index:idx_diskio_agent_ts,priority:2;index:idx_diskio_ts" json:"timestamp"` // 时间戳(毫秒)
}
DiskIOMetric 磁盘IO指标
func (DiskIOMetric) TableName ¶
func (DiskIOMetric) TableName() string
type DiskMetric ¶
type DiskMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_disk_agent_ts,priority:1" json:"agentId"` // 探针ID
MountPoint string `json:"mountPoint"` // 挂载点
Total uint64 `json:"total"` // 总容量(字节)
Used uint64 `json:"used"` // 已使用(字节)
Free uint64 `json:"free"` // 空闲(字节)
UsagePercent float64 `json:"usagePercent"` // 使用率
Timestamp int64 `gorm:"index:idx_disk_agent_ts,priority:2;index:idx_disk_ts" json:"timestamp"` // 时间戳(毫秒)
}
DiskMetric 磁盘指标
func (DiskMetric) TableName ¶
func (DiskMetric) TableName() string
type GPUMetric ¶
type GPUMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_gpu_agent_idx_ts,priority:1" json:"agentId"` // 探针ID
Index int `gorm:"index:idx_gpu_agent_idx_ts,priority:2" json:"index"` // GPU索引
Name string `json:"name"` // GPU名称
Utilization float64 `json:"utilization"` // GPU使用率(%)
MemoryTotal uint64 `json:"memoryTotal"` // 总显存(字节)
MemoryUsed uint64 `json:"memoryUsed"` // 已使用显存(字节)
MemoryFree uint64 `json:"memoryFree"` // 空闲显存(字节)
Temperature float64 `json:"temperature"` // 温度(℃)
PowerDraw float64 `json:"powerDraw"` // 功耗(瓦)
FanSpeed float64 `json:"fanSpeed"` // 风扇转速(%)
PerformanceState string `json:"performanceState"` // 性能状态
Timestamp int64 `gorm:"index:idx_gpu_agent_idx_ts,priority:3;index:idx_gpu_ts" json:"timestamp"` // 时间戳(毫秒)
}
GPUMetric GPU指标
type HostMetric ¶
type HostMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"uniqueIndex:ux_host_agent" json:"agentId"` // 探针ID(唯一约束用于 upsert)
OS string `json:"os"` // 操作系统
Platform string `json:"platform"` // 平台
PlatformVersion string `json:"platformVersion"` // 平台版本
KernelVersion string `json:"kernelVersion"` // 内核版本
KernelArch string `json:"kernelArch"` // 内核架构
Uptime uint64 `json:"uptime"` // 运行时间(秒)
BootTime uint64 `json:"bootTime"` // 启动时间(Unix时间戳-秒)
Procs uint64 `json:"procs"` // 进程数
Timestamp int64 `gorm:"index:idx_host_ts" json:"timestamp"` // 时间戳(毫秒)
}
HostMetric 主机信息指标
func (HostMetric) TableName ¶
func (HostMetric) TableName() string
type MemoryMetric ¶
type MemoryMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_mem_agent_ts,priority:1" json:"agentId"` // 探针ID
Total uint64 `json:"total"` // 总内存(字节)
Used uint64 `json:"used"` // 已使用(字节)
Free uint64 `json:"free"` // 空闲(字节)
Available uint64 `json:"available"` // 可用内存(字节)
UsagePercent float64 `json:"usagePercent"` // 使用率
SwapTotal uint64 `json:"swapTotal"` // 总交换空间(字节)
SwapUsed uint64 `json:"swapUsed"` // 已使用交换空间(字节)
SwapFree uint64 `json:"swapFree"` // 空闲交换空间(字节)
Timestamp int64 `gorm:"index:idx_mem_agent_ts,priority:2;index:idx_mem_ts" json:"timestamp"` // 时间戳(毫秒)
}
MemoryMetric 内存指标
func (MemoryMetric) TableName ¶
func (MemoryMetric) TableName() string
type MonitorMetric ¶
type MonitorMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentId string `gorm:"index:idx_mon_agent_monitor_ts,priority:1" json:"agentId"` // 探针ID
MonitorId string `gorm:"index:idx_mon_agent_monitor_ts,priority:2;index:idx_mon_type_monitor_ts,priority:2" json:"monitorId"` // 监控项ID
Type string `gorm:"index:idx_mon_type_monitor_ts,priority:1" json:"type"` // 监控类型: http, tcp
Target string `json:"target"` // 监控目标
Status string `json:"status"` // 状态: up, down
StatusCode int `json:"statusCode"` // HTTP状态码
ResponseTime int64 `json:"responseTime"` // 响应时间(毫秒)
Error string `json:"error"` // 错误信息
Message string `json:"message"` // 附加信息
ContentMatch bool `json:"contentMatch"` // 内容匹配结果
CertExpiryTime int64 `json:"certExpiryTime"` // 证书过期时间(毫秒时间戳), 0表示无证书
CertDaysLeft int `json:"certDaysLeft"` // 证书剩余天数
Timestamp int64 `gorm:"index:idx_mon_agent_monitor_ts,priority:3;index:idx_mon_type_monitor_ts,priority:3;index:idx_mon_ts" json:"timestamp"` // 时间戳(毫秒)
}
MonitorMetric 监控指标
func (MonitorMetric) TableName ¶
func (MonitorMetric) TableName() string
type NetworkConnectionMetric ¶
type NetworkConnectionMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_netconn_agent_ts,priority:1" json:"agentId"` // 探针ID
Established uint32 `json:"established"` // ESTABLISHED 状态连接数
SynSent uint32 `json:"synSent"` // SYN_SENT 状态连接数
SynRecv uint32 `json:"synRecv"` // SYN_RECV 状态连接数
FinWait1 uint32 `json:"finWait1"` // FIN_WAIT1 状态连接数
FinWait2 uint32 `json:"finWait2"` // FIN_WAIT2 状态连接数
TimeWait uint32 `json:"timeWait"` // TIME_WAIT 状态连接数
Close uint32 `json:"close"` // CLOSE 状态连接数
CloseWait uint32 `json:"closeWait"` // CLOSE_WAIT 状态连接数
LastAck uint32 `json:"lastAck"` // LAST_ACK 状态连接数
Listen uint32 `json:"listen"` // LISTEN 状态连接数
Closing uint32 `json:"closing"` // CLOSING 状态连接数
Total uint32 `json:"total"` // 总连接数
Timestamp int64 `gorm:"index:idx_netconn_agent_ts,priority:2;index:idx_netconn_ts" json:"timestamp"` // 时间戳(毫秒)
}
NetworkConnectionMetric 网络连接统计指标
func (NetworkConnectionMetric) TableName ¶
func (NetworkConnectionMetric) TableName() string
type NetworkMetric ¶
type NetworkMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_net_agent_ts,priority:1" json:"agentId"` // 探针ID
Interface string `json:"interface"` // 网卡名称
BytesSentRate uint64 `json:"bytesSentRate"` // 发送速率(字节/秒)
BytesRecvRate uint64 `json:"bytesRecvRate"` // 接收速率(字节/秒)
BytesSentTotal uint64 `json:"bytesSentTotal"` // 累计发送字节数
BytesRecvTotal uint64 `json:"bytesRecvTotal"` // 累计接收字节数
Timestamp int64 `gorm:"index:idx_net_agent_ts,priority:2;index:idx_net_ts" json:"timestamp"` // 时间戳(毫秒)
}
NetworkMetric 网络指标
func (NetworkMetric) TableName ¶
func (NetworkMetric) TableName() string
type TemperatureMetric ¶
type TemperatureMetric struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AgentID string `gorm:"index:idx_temp_agent_sensor_ts,priority:1" json:"agentId"` // 探针ID
SensorKey string `gorm:"index:idx_temp_agent_sensor_ts,priority:2" json:"sensorKey"` // 传感器标识
SensorLabel string `json:"sensorLabel"` // 传感器标签
Temperature float64 `json:"temperature"` // 温度(℃)
Timestamp int64 `gorm:"index:idx_temp_agent_sensor_ts,priority:3;index:idx_temp_ts" json:"timestamp"` // 时间戳(毫秒)
}
TemperatureMetric 温度指标
func (TemperatureMetric) TableName ¶
func (TemperatureMetric) TableName() string
Click to show internal directories.
Click to hide internal directories.