collect top process

This commit is contained in:
henrygd
2025-11-03 21:50:33 -05:00
parent fc0947aa04
commit fbbdd49fc2
3 changed files with 134 additions and 0 deletions

View File

@@ -98,6 +98,15 @@ func (a *Agent) getSystemStats(cacheTimeMs uint16) system.Stats {
slog.Error("Error getting cpu metrics", "err", err)
}
if topProcess, err := getTopCpuProcess(cacheTimeMs); err == nil {
if topProcess != nil {
topProcess.Percent = twoDecimals(topProcess.Percent)
systemStats.TopCpuProcess = topProcess
}
} else {
slog.Error("Error getting top cpu process", "err", err)
}
// per-core cpu usage
if perCoreUsage, err := getPerCoreCpuUsage(cacheTimeMs); err == nil {
systemStats.CpuCoresUsage = perCoreUsage