mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-12 16:44:18 -08:00
Scrape thermal_zone temperatures (#1425)
* Scrape thermal_zone temperatures Signed-off-by: Richard Kojedzinszky <richard@kojedz.in>
This commit is contained in:
parent
10146109ec
commit
75462bf4fe
|
@ -22,6 +22,7 @@
|
||||||
* [BUGFIX] Renamed label `state` to `name` on `node_systemd_service_restart_total`. #1393
|
* [BUGFIX] Renamed label `state` to `name` on `node_systemd_service_restart_total`. #1393
|
||||||
* [BUGFIX] Fix netdev nil reference on Darwin #1414
|
* [BUGFIX] Fix netdev nil reference on Darwin #1414
|
||||||
* [BUGFIX] Strip path.rootfs from mountpoint labels #1421
|
* [BUGFIX] Strip path.rootfs from mountpoint labels #1421
|
||||||
|
* [FEATURE] Add new thermal_zone collector #1425
|
||||||
|
|
||||||
## 0.18.1 / 2019-06-04
|
## 0.18.1 / 2019-06-04
|
||||||
|
|
||||||
|
|
|
@ -2488,6 +2488,7 @@ node_scrape_collector_success{collector="schedstat"} 1
|
||||||
node_scrape_collector_success{collector="sockstat"} 1
|
node_scrape_collector_success{collector="sockstat"} 1
|
||||||
node_scrape_collector_success{collector="stat"} 1
|
node_scrape_collector_success{collector="stat"} 1
|
||||||
node_scrape_collector_success{collector="textfile"} 1
|
node_scrape_collector_success{collector="textfile"} 1
|
||||||
|
node_scrape_collector_success{collector="thermal_zone"} 1
|
||||||
node_scrape_collector_success{collector="vmstat"} 1
|
node_scrape_collector_success{collector="vmstat"} 1
|
||||||
node_scrape_collector_success{collector="wifi"} 1
|
node_scrape_collector_success{collector="wifi"} 1
|
||||||
node_scrape_collector_success{collector="xfs"} 1
|
node_scrape_collector_success{collector="xfs"} 1
|
||||||
|
@ -2539,6 +2540,9 @@ node_sockstat_sockets_used 229
|
||||||
# HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise
|
# HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise
|
||||||
# TYPE node_textfile_scrape_error gauge
|
# TYPE node_textfile_scrape_error gauge
|
||||||
node_textfile_scrape_error 0
|
node_textfile_scrape_error 0
|
||||||
|
# HELP node_thermal_zone_temp Zone temperature in Celsius
|
||||||
|
# TYPE node_thermal_zone_temp gauge
|
||||||
|
node_thermal_zone_temp{type="cpu-thermal",zone="0"} 12.376
|
||||||
# HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill.
|
# HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill.
|
||||||
# TYPE node_vmstat_oom_kill untyped
|
# TYPE node_vmstat_oom_kill untyped
|
||||||
node_vmstat_oom_kill 0
|
node_vmstat_oom_kill 0
|
||||||
|
|
|
@ -2488,6 +2488,7 @@ node_scrape_collector_success{collector="schedstat"} 1
|
||||||
node_scrape_collector_success{collector="sockstat"} 1
|
node_scrape_collector_success{collector="sockstat"} 1
|
||||||
node_scrape_collector_success{collector="stat"} 1
|
node_scrape_collector_success{collector="stat"} 1
|
||||||
node_scrape_collector_success{collector="textfile"} 1
|
node_scrape_collector_success{collector="textfile"} 1
|
||||||
|
node_scrape_collector_success{collector="thermal_zone"} 1
|
||||||
node_scrape_collector_success{collector="vmstat"} 1
|
node_scrape_collector_success{collector="vmstat"} 1
|
||||||
node_scrape_collector_success{collector="wifi"} 1
|
node_scrape_collector_success{collector="wifi"} 1
|
||||||
node_scrape_collector_success{collector="xfs"} 1
|
node_scrape_collector_success{collector="xfs"} 1
|
||||||
|
@ -2539,6 +2540,9 @@ node_sockstat_sockets_used 229
|
||||||
# HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise
|
# HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise
|
||||||
# TYPE node_textfile_scrape_error gauge
|
# TYPE node_textfile_scrape_error gauge
|
||||||
node_textfile_scrape_error 0
|
node_textfile_scrape_error 0
|
||||||
|
# HELP node_thermal_zone_temp Zone temperature in Celsius
|
||||||
|
# TYPE node_thermal_zone_temp gauge
|
||||||
|
node_thermal_zone_temp{type="cpu-thermal",zone="0"} 12.376
|
||||||
# HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill.
|
# HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill.
|
||||||
# TYPE node_vmstat_oom_kill untyped
|
# TYPE node_vmstat_oom_kill untyped
|
||||||
node_vmstat_oom_kill 0
|
node_vmstat_oom_kill 0
|
||||||
|
|
|
@ -920,6 +920,12 @@ Lines: 1
|
||||||
1
|
1
|
||||||
Mode: 644
|
Mode: 644
|
||||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Directory: sys/class/thermal
|
||||||
|
Mode: 755
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Path: sys/class/thermal/thermal_zone0
|
||||||
|
SymlinkTo: ../../devices/virtual/thermal/thermal_zone0
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Directory: sys/devices
|
Directory: sys/devices
|
||||||
Mode: 755
|
Mode: 755
|
||||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -2460,6 +2466,30 @@ local_node 26719046550
|
||||||
other_node 9860526920
|
other_node 9860526920
|
||||||
Mode: 644
|
Mode: 644
|
||||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Directory: sys/devices/virtual
|
||||||
|
Mode: 755
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Directory: sys/devices/virtual/thermal
|
||||||
|
Mode: 755
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Directory: sys/devices/virtual/thermal/thermal_zone0
|
||||||
|
Mode: 755
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Path: sys/devices/virtual/thermal/thermal_zone0/policy
|
||||||
|
Lines: 1
|
||||||
|
step_wise
|
||||||
|
Mode: 644
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Path: sys/devices/virtual/thermal/thermal_zone0/temp
|
||||||
|
Lines: 1
|
||||||
|
12376
|
||||||
|
Mode: 644
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Path: sys/devices/virtual/thermal/thermal_zone0/type
|
||||||
|
Lines: 1
|
||||||
|
cpu-thermal
|
||||||
|
Mode: 644
|
||||||
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Directory: sys/fs
|
Directory: sys/fs
|
||||||
Mode: 755
|
Mode: 755
|
||||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
68
collector/thermal_zone_linux.go
Normal file
68
collector/thermal_zone_linux.go
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
// Copyright 2019 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build !nothermalzone
|
||||||
|
|
||||||
|
package collector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/procfs/sysfs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type thermalZoneCollector struct {
|
||||||
|
fs sysfs.FS
|
||||||
|
zoneTemp *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerCollector("thermal_zone", defaultEnabled, NewThermalZoneCollector)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewThermalZoneCollector returns a new Collector exposing kernel/system statistics.
|
||||||
|
func NewThermalZoneCollector() (Collector, error) {
|
||||||
|
fs, err := sysfs.NewFS(*sysPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to open sysfs: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &thermalZoneCollector{
|
||||||
|
fs: fs,
|
||||||
|
zoneTemp: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(namespace, "thermal_zone", "temp"),
|
||||||
|
"Zone temperature in Celsius",
|
||||||
|
[]string{"zone", "type"}, nil,
|
||||||
|
),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *thermalZoneCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
|
thermalZones, err := c.fs.ClassThermalZoneStats()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, stats := range thermalZones {
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.zoneTemp,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(stats.Temp)/1000.0,
|
||||||
|
stats.Name,
|
||||||
|
stats.Type,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ enabled_collectors=$(cat << COLLECTORS
|
||||||
schedstat
|
schedstat
|
||||||
sockstat
|
sockstat
|
||||||
stat
|
stat
|
||||||
|
thermal_zone
|
||||||
textfile
|
textfile
|
||||||
bonding
|
bonding
|
||||||
vmstat
|
vmstat
|
||||||
|
|
Loading…
Reference in a new issue