mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-23 20:36:21 +01:00
Merge pull request #1445 from davemcphee/coolingDevice
Scrape cooling_device state
This commit is contained in:
commit
7caedccd73
@ -24,8 +24,9 @@
|
||||
* [BUGFIX] Renamed label `state` to `name` on `node_systemd_service_restart_total`. #1393
|
||||
* [BUGFIX] Fix netdev nil reference on Darwin #1414
|
||||
* [BUGFIX] Strip path.rootfs from mountpoint labels #1421
|
||||
* [FEATURE] Add new thermal_zone collector #1425
|
||||
* [BUGFIX] Fix empty string in path.rootfs #1464
|
||||
* [FEATURE] Add new thermal_zone collector #1425
|
||||
* [FEATURE] Add new cooling_device metrics to thermal zone collector #1445
|
||||
|
||||
## 0.18.1 / 2019-06-04
|
||||
|
||||
|
@ -55,6 +55,7 @@ schedstat | Exposes task scheduler statistics from `/proc/schedstat`. | Linux
|
||||
sockstat | Exposes various statistics from `/proc/net/sockstat`. | Linux
|
||||
stat | Exposes various statistics from `/proc/stat`. This includes boot time, forks and interrupts. | Linux
|
||||
textfile | Exposes statistics read from local disk. The `--collector.textfile.directory` flag must be set. | _any_
|
||||
thermal\_zone | Exposes thermal zone & cooling device statistics from `/sys/class/thermal`. | Linux
|
||||
time | Exposes the current system time. | _any_
|
||||
timex | Exposes selected adjtimex(2) system call stats. | Linux
|
||||
uname | Exposes system information as provided by the uname system call. | Darwin, FreeBSD, Linux, OpenBSD
|
||||
|
@ -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…
Reference in New Issue
Block a user