Add CPU monitoring to stream health overview

This commit is contained in:
Gabe Kangas 2022-03-26 13:01:23 -07:00
parent 83cec52104
commit 35801ff33a
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA

View File

@ -6,6 +6,7 @@ import (
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/utils"
)
var errorMessages = map[string]string{
@ -85,6 +86,19 @@ func generateStreamHealthOverview() {
}
}
// Report high CPU use.
if unhealthyClientCount == 0 && len(metrics.CPUUtilizations) > 2 {
recentCPUUses := metrics.CPUUtilizations[len(metrics.CPUUtilizations)-2:]
values := make([]float64, len(recentCPUUses))
for i, val := range recentCPUUses {
values[i] = val.Value
}
recentCPUUse := utils.Avg(values)
if recentCPUUse > 90 {
overview.Message = "The CPU usage on your server is over 90%. This may cause video to be provided slower than necessarily, causing buffering for your viewers. Consider increasing the resources available or reducing the number of output variants you made available."
}
}
if unhealthyClientCount == 0 {
return
}