Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskIOSummary ¶ added in v0.1.9
type DiskIOSummary struct {
TotalReadBytesRate uint64 `json:"totalReadBytesRate"` // 总读取速率(字节/秒)
TotalWriteBytesRate uint64 `json:"totalWriteBytesRate"` // 总写入速率(字节/秒)
TotalDevices int `json:"totalDevices"` // 设备数量
}
DiskIOSummary 磁盘IO汇总数据
type DiskSummary ¶
type DiskSummary struct {
UsagePercent float64 `json:"usagePercent"` // 平均使用率
TotalDisks int `json:"totalDisks"` // 磁盘数量
Total uint64 `json:"total"` // 总容量(字节)
Used uint64 `json:"used"` // 已使用(字节)
Free uint64 `json:"free"` // 空闲(字节)
}
DiskSummary 磁盘汇总数据
type GetMetricsResponse ¶
type GetMetricsResponse struct {
AgentID string `json:"agentId"`
Type string `json:"type"`
Range string `json:"range"`
Series []Series `json:"series"`
}
GetMetricsResponse 统一的查询响应格式
type LatestMetrics ¶
type LatestMetrics struct {
// Timestamp 探针采集该批指标的时间戳(毫秒),用于前端实时图表追加点位
Timestamp int64 `json:"timestamp,omitempty"`
CPU *protocol.CPUData `json:"cpu,omitempty"`
Memory *protocol.MemoryData `json:"memory,omitempty"`
Disk *DiskSummary `json:"disk,omitempty"`
DiskIO *DiskIOSummary `json:"diskIO,omitempty"`
Network *NetworkSummary `json:"network,omitempty"`
NetworkInterfaces []protocol.NetworkData `json:"networkInterfaces,omitempty"`
NetworkConnection *protocol.NetworkConnectionData `json:"networkConnection,omitempty"`
Host *protocol.HostInfoData `json:"host,omitempty"`
GPU []protocol.GPUData `json:"gpu,omitempty"`
Temp []protocol.TemperatureData `json:"temperature,omitempty"`
Monitors []protocol.MonitorData `json:"monitors,omitempty"`
// contains filtered or unexported fields
}
LatestMetrics 最新指标数据(用于API响应)
并发:写者(websocket 上报路径)通过 Update 取写锁修改字段;读者(HTTP latest 接口) 通过 Snapshot 取读锁拷贝出独立对象,避免序列化时与写者并发产生 data race。 写者必须始终“整体替换”内部指针/切片字段(不要原地 mutate),这样读者拿到的浅拷贝 仍然指向稳定的旧值。
func (*LatestMetrics) Snapshot ¶ added in v0.1.9
func (lm *LatestMetrics) Snapshot() *LatestMetrics
Snapshot 在读锁内对当前状态做浅拷贝。返回的对象拥有独立的零值互斥量, 调用方可以安全地读取/序列化/再 sanitize(修改返回对象上的字段不会影响缓存)。 内部的指针/切片仍指向旧值,但因为写者每次都整体替换字段,所以是安全的。
func (*LatestMetrics) Update ¶ added in v0.1.9
func (lm *LatestMetrics) Update(fn func(*LatestMetrics))
Update 在写锁内执行 fn。fn 内可以读写任何字段(包括 Timestamp)。
type LatestMonitorMetrics ¶
type LatestMonitorMetrics struct {
MonitorID string `json:"monitorId"`
Agents *syncx.SafeMap[string, *protocol.MonitorData] `json:"agents"` // key: agentID
UpdatedAt int64 `json:"updatedAt"` // 最后更新时间
}
LatestMonitorMetrics 监控任务的最新指标(按 agent 分组)
type MonitorDetailResponse ¶
type MonitorDetailResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Target string `json:"target"`
ShowTargetPublic bool `json:"showTargetPublic"`
Description string `json:"description"`
Enabled bool `json:"enabled"`
Interval int `json:"interval"`
Stats *MonitorStatsResult `json:"stats"`
Agents []protocol.MonitorData `json:"agents"`
}
MonitorDetailResponse 监控详情响应(整合版)
type MonitorStatsResult ¶
type MonitorStatsResult struct {
Status string `json:"status"` // 聚合状态(up/down/unknown)
ResponseTime int64 `json:"responseTime"` // 当前平均响应时间(ms)
ResponseTimeMin int64 `json:"responseTimeMin"` // 最快响应时间(ms)
ResponseTimeMax int64 `json:"responseTimeMax"` // 最慢响应时间(ms)
CertExpiryTime int64 `json:"certExpiryTime,omitempty"` // 证书过期时间(毫秒时间戳)
CertDaysLeft int `json:"certDaysLeft,omitempty"` // 证书剩余天数
AgentCount int `json:"agentCount"` // 探针数量
AgentStats struct {
Up int `json:"up"` // 正常探针数量
Down int `json:"down"` // 异常探针数量
Unknown int `json:"unknown"` // 未知状态探针数量
} `json:"agentStats"` // 探针状态分布
LastCheckTime int64 `json:"lastCheckTime"` // 最后检测时间(毫秒时间戳)
}
MonitorStatsResult 监控统计结果(所有探针的聚合数据)
type NetworkSummary ¶
type NetworkSummary struct {
TotalBytesSentRate uint64 `json:"totalBytesSentRate"` // 总发送速率(字节/秒)
TotalBytesRecvRate uint64 `json:"totalBytesRecvRate"` // 总接收速率(字节/秒)
TotalBytesSentTotal uint64 `json:"totalBytesSentTotal"` // 累计总发送流量
TotalBytesRecvTotal uint64 `json:"totalBytesRecvTotal"` // 累计总接收流量
TotalInterfaces int `json:"totalInterfaces"` // 网卡数量
}
NetworkSummary 网络汇总数据
type PublicMonitorOverview ¶
type PublicMonitorOverview struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Target string `json:"target"`
ShowTargetPublic bool `json:"showTargetPublic"` // 在公开页面是否显示目标地址
Description string `json:"description"`
Enabled bool `json:"enabled"`
Interval int `json:"interval"`
AgentCount int `json:"agentCount"`
Status string `json:"status"` // up/down/unknown
ResponseTime int64 `json:"responseTime"` // 当前平均响应时间(ms)
ResponseTimeMin int64 `json:"responseTimeMin"` // 最快响应时间(ms)
ResponseTimeMax int64 `json:"responseTimeMax"` // 最慢响应时间(ms)
CertExpiryTime int64 `json:"certExpiryTime,omitempty"` // 证书过期时间(毫秒时间戳)
CertDaysLeft int `json:"certDaysLeft,omitempty"` // 证书剩余天数
AgentStats struct {
Up int `json:"up"` // 正常探针数量
Down int `json:"down"` // 异常探针数量
Unknown int `json:"unknown"` // 未知状态探针数量
} `json:"agentStats"` // 探针状态分布
LastCheckTime int64 `json:"lastCheckTime"` // 最后检测时间
}
PublicMonitorOverview 用于公开展示的监控配置及汇总数据
Click to show internal directories.
Click to hide internal directories.