mirror of
https://github.com/owncast/owncast.git
synced 2024-11-21 12:18:02 +03:00
Fix CPU usage collection panic with default zero value. Closes #2423
This commit is contained in:
parent
77d3f59ca6
commit
f946b73f16
1 changed files with 8 additions and 1 deletions
|
@ -24,7 +24,14 @@ func collectCPUUtilization() {
|
|||
return
|
||||
}
|
||||
|
||||
metricValue := TimestampedValue{time.Now(), v[0]}
|
||||
// Default to zero but try to use the cumulative values of all the CPUs
|
||||
// if values exist.
|
||||
value := 0.0
|
||||
if len(v) > 0 {
|
||||
value = v[0]
|
||||
}
|
||||
|
||||
metricValue := TimestampedValue{time.Now(), value}
|
||||
metrics.CPUUtilizations = append(metrics.CPUUtilizations, metricValue)
|
||||
cpuUsage.Set(metricValue.Value)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue