mirror of
https://github.com/oneclickvirt/basics.git
synced 2025-10-09 18:40:20 +08:00
fix: 修复GPU使用率检测
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 本文件夹 network 修改需要同步 https://github.com/oneclickvirt/security 否则 goecs 无法使用
|
||||||
func TestIpv4SecurityCheck(t *testing.T) {
|
func TestIpv4SecurityCheck(t *testing.T) {
|
||||||
// 全项测试
|
// 全项测试
|
||||||
ipInfo, _, _ := NetworkCheck("both", false, "zh")
|
ipInfo, _, _ := NetworkCheck("both", false, "zh")
|
||||||
|
@@ -43,7 +43,6 @@ func updateGPUStat(gpuStat *uint64, wg *sync.WaitGroup) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer atomic.StoreInt32(&updateGPUStatus, 0)
|
defer atomic.StoreInt32(&updateGPUStatus, 0)
|
||||||
|
|
||||||
for statDataFetchAttempts["GPU"] < maxDeviceDataFetchAttempts {
|
for statDataFetchAttempts["GPU"] < maxDeviceDataFetchAttempts {
|
||||||
gs, err := gpustat.GetGPUStat()
|
gs, err := gpustat.GetGPUStat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -74,7 +73,9 @@ func getGPUInfo(ret *model.SystemInfo) (*model.SystemInfo, error) {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go updateGPUStat(&gpuStat, &wg)
|
go updateGPUStat(&gpuStat, &wg)
|
||||||
wg.Wait() // 等待 updateGPUStat 完成
|
wg.Wait() // 等待 updateGPUStat 完成
|
||||||
|
if math.Float64frombits(gpuStat) > 0 {
|
||||||
ret.GpuStats = fmt.Sprintf("%f", math.Float64frombits(gpuStat))
|
ret.GpuStats = fmt.Sprintf("%f", math.Float64frombits(gpuStat))
|
||||||
|
}
|
||||||
return ret, nil
|
return ret, nil
|
||||||
} else {
|
} else {
|
||||||
hostDataFetchAttempts["GPU"]++
|
hostDataFetchAttempts["GPU"]++
|
||||||
|
Reference in New Issue
Block a user