新增Linux GPU监控功能

参考了nezha-agent。实现了Linux服务器下NVIDIA显卡的监控。
通过 --gpu 参数启用显卡监控功能。
支持多显卡,显卡使用率,显存使用率监控
实现了AMD显卡的监控,但是未经过测试
This commit is contained in:
kdwycz
2025-09-10 16:26:55 +08:00
parent c6d3754938
commit 5304a68d5d
9 changed files with 825 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
//go:build !linux
package monitoring
import (
"errors"
)
// DetailedGPUInfo 详细GPU信息结构体
type DetailedGPUInfo struct {
Name string `json:"name"` // GPU型号
MemoryTotal uint64 `json:"memory_total"` // 总显存 (字节)
MemoryUsed uint64 `json:"memory_used"` // 已用显存 (字节)
Utilization float64 `json:"utilization"` // GPU使用率 (0-100)
Temperature uint64 `json:"temperature"` // 温度 (摄氏度)
}
// GetDetailedGPUHost 获取GPU型号信息 - 回退实现
func GetDetailedGPUHost() ([]string, error) {
return nil, errors.New("detailed GPU monitoring not supported on this platform")
}
// GetDetailedGPUState 获取GPU使用率 - 回退实现
func GetDetailedGPUState() ([]float64, error) {
return nil, errors.New("detailed GPU monitoring not supported on this platform")
}
// GetDetailedGPUInfo 获取详细GPU信息 - 回退实现
func GetDetailedGPUInfo() ([]DetailedGPUInfo, error) {
return nil, errors.New("detailed GPU monitoring not supported on this platform")
}