Skip to content

Commit c72d7b4

Browse files
committed
fix cpu usage value is missing
1 parent bf6a8b8 commit c72d7b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

config/manager.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ func (m *Manager) FetchProfile() *domain.AgentProfile {
106106
vmStat, _ := mem.VirtualMemory()
107107
diskStat, _ := disk.Usage("/")
108108

109+
cpuUsage := float64(0)
110+
if len(percent) > 0 {
111+
cpuUsage = percent[0]
112+
}
113+
109114
return &domain.AgentProfile{
110115
CpuNum: nCpu,
111-
CpuUsage: percent[0],
116+
CpuUsage: cpuUsage,
112117
TotalMemory: util.ByteToMB(vmStat.Total),
113118
FreeMemory: util.ByteToMB(vmStat.Available),
114119
TotalDisk: util.ByteToMB(diskStat.Total),

0 commit comments

Comments
 (0)