Hardware status admin api (#218)

* Add metrics for disk usage

* Add admin API for hardware metrics

* Fix error message alert
This commit is contained in:
Gabe Kangas
2020-10-02 12:18:08 -07:00
committed by GitHub
parent f4fdc6c951
commit e042c85f88
5 changed files with 62 additions and 11 deletions

View File

@@ -5,21 +5,25 @@ import (
)
// How often we poll for updates
const metricsPollingInterval = 15 * time.Second
const metricsPollingInterval = 1 * time.Minute
type metrics struct {
CPUUtilizations []timestampedValue
RAMUtilizations []timestampedValue
Viewers []timestampedValue
// CollectedMetrics stores different collected + timestamped values
type CollectedMetrics struct {
CPUUtilizations []timestampedValue `json:"cpu"`
RAMUtilizations []timestampedValue `json:"memory"`
DiskUtilizations []timestampedValue `json:"disk"`
Viewers []timestampedValue `json:"-"`
}
// Metrics is the shared Metrics instance
var Metrics *metrics
var Metrics *CollectedMetrics
// Start will begin the metrics collection and alerting
func Start() {
Metrics = new(metrics)
startViewerCollectionMetrics()
Metrics = new(CollectedMetrics)
go startViewerCollectionMetrics()
handlePolling()
for range time.Tick(metricsPollingInterval) {
handlePolling()
@@ -30,6 +34,7 @@ func handlePolling() {
// Collect hardware stats
collectCPUUtilization()
collectRAMUtilization()
collectDiskUtilization()
// Alerting
handleAlerting()