chore: Add CPU core count to CPUMetrics

This commit adds the `cores` field to the `CPUMetrics` struct in order to include the number of CPU cores in the collected metrics. This information is useful for understanding the processing power of the server.
This commit is contained in:
Simon Larsen
2024-07-02 13:54:04 +01:00
parent 0df7209723
commit 9791aa1259
7 changed files with 162 additions and 8 deletions

View File

@@ -70,4 +70,10 @@ sudo ./oneuptime-infrastructure-agent configure --secret-key=YOUR_SECRET_KEY --o
```bash
sudo ./oneuptime-infrastructure-agent start
```
### Stopping the agent
```bash
sudo ./oneuptime-infrastructure-agent stop
```

View File

@@ -2,4 +2,5 @@ package model
type CPUMetrics struct {
PercentUsed float64 `json:"percentUsed"`
Cores int `json:"cores"`
}

View File

@@ -54,8 +54,11 @@ func GetCpuMetrics() *model.CPUMetrics {
}
cpuUsagePercent := (1 - idleDelta/totalDelta) * 100
numberOfCpuCores, err := cpu.Counts(true)
return &model.CPUMetrics{
PercentUsed: cpuUsagePercent,
Cores: numberOfCpuCores,
}
}