移除遗留的 HostMetric 相关代码
This commit is contained in:
1 parent
c5233ade31
commit
e7981bb69e
12 files changed
+128
-213
No files matched your search
@@ -3,6 +3,7 @@ package collector
|
||||
import (
|
||||
"github.com/dushixiang/pika/internal/protocol"
|
||||
"github.com/shirou/gopsutil/v4/host"
|
||||
"github.com/shirou/gopsutil/v4/load"
|
||||
)
|
||||
|
||||
// HostCollector 主机信息采集器
|
||||
@@ -33,6 +34,12 @@ func (h *HostCollector) Collect() (*protocol.HostInfoData, error) {
|
||||
KernelArch: hostInfo.KernelArch,
|
||||
}
|
||||
|
||||
if loadAvg, err := load.Avg(); err == nil && loadAvg != nil {
|
||||
hostData.Load1 = loadAvg.Load1
|
||||
hostData.Load5 = loadAvg.Load5
|
||||
hostData.Load15 = loadAvg.Load15
|
||||
}
|
||||
|
||||
// 尝试获取虚拟化信息
|
||||
if hostInfo.VirtualizationSystem != "" {
|
||||
hostData.VirtualizationSystem = hostInfo.VirtualizationSystem
|
||||
|
||||
@@ -528,7 +528,7 @@ func (a *Agent) collectAndSendAllMetrics(manager *collector.Manager) error {
|
||||
hasError = true
|
||||
}
|
||||
|
||||
// 主机信息
|
||||
// 主机信息(包含 Load)
|
||||
if err := manager.CollectAndSendHost(writer); err != nil {
|
||||
slog.Warn("发送主机信息失败", "error", err)
|
||||
hasError = true
|
||||
|
||||
Reference in new issue
Block a user