Scrape cooling_device state
Signed-off-by: Alex Schmitz <alex.schmitz@gmail.com>
This commit is contained in:
parent
d3478a207e
commit
664025d60c
11 changed files with 557 additions and 3 deletions
|
|
@ -22,9 +22,14 @@ import (
|
|||
"github.com/prometheus/procfs/sysfs"
|
||||
)
|
||||
|
||||
const coolingDevice = "cooling_device"
|
||||
const thermalZone = "thermal_zone"
|
||||
|
||||
type thermalZoneCollector struct {
|
||||
fs sysfs.FS
|
||||
zoneTemp *prometheus.Desc
|
||||
fs sysfs.FS
|
||||
coolingDeviceCurState *prometheus.Desc
|
||||
coolingDeviceMaxState *prometheus.Desc
|
||||
zoneTemp *prometheus.Desc
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
@ -41,10 +46,20 @@ func NewThermalZoneCollector() (Collector, error) {
|
|||
return &thermalZoneCollector{
|
||||
fs: fs,
|
||||
zoneTemp: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "thermal_zone", "temp"),
|
||||
prometheus.BuildFQName(namespace, thermalZone, "temp"),
|
||||
"Zone temperature in Celsius",
|
||||
[]string{"zone", "type"}, nil,
|
||||
),
|
||||
coolingDeviceCurState: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, coolingDevice, "cur_state"),
|
||||
"Current throttle state of the cooling device",
|
||||
[]string{"name", "type"}, nil,
|
||||
),
|
||||
coolingDeviceMaxState: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, coolingDevice, "max_state"),
|
||||
"Maximum throttle state of the cooling device",
|
||||
[]string{"name", "type"}, nil,
|
||||
),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -64,5 +79,28 @@ func (c *thermalZoneCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
)
|
||||
}
|
||||
|
||||
coolingDevices, err := c.fs.ClassCoolingDeviceStats()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, stats := range coolingDevices {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.coolingDeviceCurState,
|
||||
prometheus.GaugeValue,
|
||||
float64(stats.CurState),
|
||||
stats.Name,
|
||||
stats.Type,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.coolingDeviceMaxState,
|
||||
prometheus.GaugeValue,
|
||||
float64(stats.MaxState),
|
||||
stats.Name,
|
||||
stats.Type,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue