func (c *SystemCollector) Collect(ch chan<- prometheus.Metric) {
	for _, m := range c.metrics() {
		ch <- m
	}
}
Collect sends the metric values for each metric pertaining to the global
cluster usage over to the provided prometheus Metric channel.
package edgemaxexporter
import (
	"time"
	"github.com/mdlayher/edgemax"
	"github.com/prometheus/client_golang/prometheus"
)
type SystemCollector struct {
	CPUPercent    prometheus.Gauge
	UptimeSeconds prometheus.Gauge
	MemoryPercent prometheus.Gauge
	statC <-chan *edgemax.SystemStats
}
var _ prometheus.Collector = &SystemCollector{}
func NewSystemCollector(statC <-chan *edgemax.SystemStats) *SystemCollector {
	const (
		subsystem = "system"
	)
	collector := &SystemCollector{
		CPUPercent: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "cpu_percent",
			Help:      "System CPU usage percentage",
		}),
		UptimeSeconds: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "uptime_seconds",
			Help:      "System uptime in seconds",
		}),
		MemoryPercent: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "memory_percent",
			Help:      "System memory usage percentage",
		}),
		statC: statC,
	}
	go collector.collect()
	return collector
}
func (c *SystemCollector) metrics() []prometheus.Metric {
	return []prometheus.Metric{
		c.CPUPercent,
		c.UptimeSeconds,
		c.MemoryPercent,
	}
}
func (c *SystemCollector) collect() {
	for s := range c.statC {
		c.CPUPercent.Set(float64(s.CPU))
		c.UptimeSeconds.Set(float64(s.Uptime / time.Second))
		c.MemoryPercent.Set(float64(s.Memory))
	}
}
func (c *SystemCollector) Describe(ch chan<- *prometheus.Desc) {
	for _, m := range c.metrics() {
		ch <- m.Desc()
	}
}