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
|
|
@ -178,6 +178,12 @@ node_buddyinfo_blocks{node="0",size="9",zone="Normal"} 0
|
|||
# HELP node_context_switches_total Total number of context switches.
|
||||
# TYPE node_context_switches_total counter
|
||||
node_context_switches_total 3.8014093e+07
|
||||
# HELP node_cooling_device_cur_state Current throttle state of the cooling device
|
||||
# TYPE node_cooling_device_cur_state gauge
|
||||
node_cooling_device_cur_state{name="0",type="Processor"} 0
|
||||
# HELP node_cooling_device_max_state Maximum throttle state of the cooling device
|
||||
# TYPE node_cooling_device_max_state gauge
|
||||
node_cooling_device_max_state{name="0",type="Processor"} 3
|
||||
# HELP node_cpu_core_throttles_total Number of times this cpu core has been throttled.
|
||||
# TYPE node_cpu_core_throttles_total counter
|
||||
node_cpu_core_throttles_total{core="0",package="0"} 5
|
||||
|
|
|
|||
|
|
@ -178,6 +178,12 @@ node_buddyinfo_blocks{node="0",size="9",zone="Normal"} 0
|
|||
# HELP node_context_switches_total Total number of context switches.
|
||||
# TYPE node_context_switches_total counter
|
||||
node_context_switches_total 3.8014093e+07
|
||||
# HELP node_cooling_device_cur_state Current throttle state of the cooling device
|
||||
# TYPE node_cooling_device_cur_state gauge
|
||||
node_cooling_device_cur_state{name="0",type="Processor"} 0
|
||||
# HELP node_cooling_device_max_state Maximum throttle state of the cooling device
|
||||
# TYPE node_cooling_device_max_state gauge
|
||||
node_cooling_device_max_state{name="0",type="Processor"} 3
|
||||
# HELP node_cpu_core_throttles_total Number of times this cpu core has been throttled.
|
||||
# TYPE node_cpu_core_throttles_total counter
|
||||
node_cpu_core_throttles_total{core="0",package="0"} 5
|
||||
|
|
|
|||
|
|
@ -926,6 +926,9 @@ Mode: 755
|
|||
Path: sys/class/thermal/thermal_zone0
|
||||
SymlinkTo: ../../devices/virtual/thermal/thermal_zone0
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/thermal/cooling_device0
|
||||
SymlinkTo: ../../devices/virtual/thermal/cooling_device0
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -2472,6 +2475,24 @@ Mode: 755
|
|||
Directory: sys/devices/virtual/thermal
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/virtual/thermal/cooling_device0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/virtual/thermal/cooling_device0/cur_state
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/virtual/thermal/cooling_device0/max_state
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/virtual/thermal/cooling_device0/type
|
||||
Lines: 1
|
||||
Processor
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/virtual/thermal/thermal_zone0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
|||
|
|
@ -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