This commit is contained in:
Akizon77
2025-04-11 17:26:34 +08:00
commit c2a9148d4c
14 changed files with 705 additions and 0 deletions

25
monitoring/load.go Normal file
View File

@@ -0,0 +1,25 @@
package monitoring
import (
"github.com/shirou/gopsutil/load"
)
type LoadInfo struct {
Load1 float64 `json:"load_1"`
Load5 float64 `json:"load_5"`
Load15 float64 `json:"load_15"`
}
func Load() LoadInfo {
avg, err := load.Avg()
if err != nil {
return LoadInfo{Load1: 0, Load5: 0, Load15: 0}
}
return LoadInfo{
Load1: avg.Load1,
Load5: avg.Load5,
Load15: avg.Load15,
}
}