mirror of
https://github.com/owncast/owncast.git
synced 2024-11-25 22:31:09 +03:00
236f25b772
* Add support for ending the inbound stream. Closes #191 * Add a simple success response to API requests * Add viewers over time API * Move controllers to admin directory
36 lines
649 B
Go
36 lines
649 B
Go
package metrics
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// How often we poll for updates
|
|
const metricsPollingInterval = 15 * time.Second
|
|
|
|
type metrics struct {
|
|
CPUUtilizations []timestampedValue
|
|
RAMUtilizations []timestampedValue
|
|
Viewers []timestampedValue
|
|
}
|
|
|
|
// Metrics is the shared Metrics instance
|
|
var Metrics *metrics
|
|
|
|
// Start will begin the metrics collection and alerting
|
|
func Start() {
|
|
Metrics = new(metrics)
|
|
startViewerCollectionMetrics()
|
|
|
|
for range time.Tick(metricsPollingInterval) {
|
|
handlePolling()
|
|
}
|
|
}
|
|
|
|
func handlePolling() {
|
|
// Collect hardware stats
|
|
collectCPUUtilization()
|
|
collectRAMUtilization()
|
|
|
|
// Alerting
|
|
handleAlerting()
|
|
}
|