Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Add CPU monitoring to stream health overview

Gabe Kangasf94abec78896
diff --git a/metrics/healthOverview.go b/metrics/healthOverview.go
index 897a5c0524..f4822cb352 100644
--- a/metrics/healthOverview.go
+++ b/metrics/healthOverview.go
@@ -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
}