mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
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:
@@ -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
|
||||
```
|
||||
@@ -2,4 +2,5 @@ package model
|
||||
|
||||
type CPUMetrics struct {
|
||||
PercentUsed float64 `json:"percentUsed"`
|
||||
Cores int `json:"cores"`
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user