diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | collector/fixtures/e2e-64k-page-output.txt | 4 | ||||
-rw-r--r-- | collector/fixtures/e2e-output.txt | 4 | ||||
-rw-r--r-- | collector/fixtures/sys.ttar | 30 | ||||
-rw-r--r-- | collector/thermal_zone_linux.go | 68 | ||||
-rwxr-xr-x | end-to-end-test.sh | 1 |
6 files changed, 108 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c1893f..a131266 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -22,6 +22,7 @@ | |||
22 | * [BUGFIX] Renamed label `state` to `name` on `node_systemd_service_restart_total`. #1393 | 22 | * [BUGFIX] Renamed label `state` to `name` on `node_systemd_service_restart_total`. #1393 |
23 | * [BUGFIX] Fix netdev nil reference on Darwin #1414 | 23 | * [BUGFIX] Fix netdev nil reference on Darwin #1414 |
24 | * [BUGFIX] Strip path.rootfs from mountpoint labels #1421 | 24 | * [BUGFIX] Strip path.rootfs from mountpoint labels #1421 |
25 | * [FEATURE] Add new thermal_zone collector #1425 | ||
25 | 26 | ||
26 | ## 0.18.1 / 2019-06-04 | 27 | ## 0.18.1 / 2019-06-04 |
27 | 28 | ||
diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 5e83c60..b7e56ed 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt | |||
@@ -2488,6 +2488,7 @@ node_scrape_collector_success{collector="schedstat"} 1 | |||
2488 | node_scrape_collector_success{collector="sockstat"} 1 | 2488 | node_scrape_collector_success{collector="sockstat"} 1 |
2489 | node_scrape_collector_success{collector="stat"} 1 | 2489 | node_scrape_collector_success{collector="stat"} 1 |
2490 | node_scrape_collector_success{collector="textfile"} 1 | 2490 | node_scrape_collector_success{collector="textfile"} 1 |
2491 | node_scrape_collector_success{collector="thermal_zone"} 1 | ||
2491 | node_scrape_collector_success{collector="vmstat"} 1 | 2492 | node_scrape_collector_success{collector="vmstat"} 1 |
2492 | node_scrape_collector_success{collector="wifi"} 1 | 2493 | node_scrape_collector_success{collector="wifi"} 1 |
2493 | node_scrape_collector_success{collector="xfs"} 1 | 2494 | node_scrape_collector_success{collector="xfs"} 1 |
@@ -2539,6 +2540,9 @@ node_sockstat_sockets_used 229 | |||
2539 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise | 2540 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise |
2540 | # TYPE node_textfile_scrape_error gauge | 2541 | # TYPE node_textfile_scrape_error gauge |
2541 | node_textfile_scrape_error 0 | 2542 | node_textfile_scrape_error 0 |
2543 | # HELP node_thermal_zone_temp Zone temperature in Celsius | ||
2544 | # TYPE node_thermal_zone_temp gauge | ||
2545 | node_thermal_zone_temp{type="cpu-thermal",zone="0"} 12.376 | ||
2542 | # HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill. | 2546 | # HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill. |
2543 | # TYPE node_vmstat_oom_kill untyped | 2547 | # TYPE node_vmstat_oom_kill untyped |
2544 | node_vmstat_oom_kill 0 | 2548 | node_vmstat_oom_kill 0 |
diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 258e765..1d392d8 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt | |||
@@ -2488,6 +2488,7 @@ node_scrape_collector_success{collector="schedstat"} 1 | |||
2488 | node_scrape_collector_success{collector="sockstat"} 1 | 2488 | node_scrape_collector_success{collector="sockstat"} 1 |
2489 | node_scrape_collector_success{collector="stat"} 1 | 2489 | node_scrape_collector_success{collector="stat"} 1 |
2490 | node_scrape_collector_success{collector="textfile"} 1 | 2490 | node_scrape_collector_success{collector="textfile"} 1 |
2491 | node_scrape_collector_success{collector="thermal_zone"} 1 | ||
2491 | node_scrape_collector_success{collector="vmstat"} 1 | 2492 | node_scrape_collector_success{collector="vmstat"} 1 |
2492 | node_scrape_collector_success{collector="wifi"} 1 | 2493 | node_scrape_collector_success{collector="wifi"} 1 |
2493 | node_scrape_collector_success{collector="xfs"} 1 | 2494 | node_scrape_collector_success{collector="xfs"} 1 |
@@ -2539,6 +2540,9 @@ node_sockstat_sockets_used 229 | |||
2539 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise | 2540 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise |
2540 | # TYPE node_textfile_scrape_error gauge | 2541 | # TYPE node_textfile_scrape_error gauge |
2541 | node_textfile_scrape_error 0 | 2542 | node_textfile_scrape_error 0 |
2543 | # HELP node_thermal_zone_temp Zone temperature in Celsius | ||
2544 | # TYPE node_thermal_zone_temp gauge | ||
2545 | node_thermal_zone_temp{type="cpu-thermal",zone="0"} 12.376 | ||
2542 | # HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill. | 2546 | # HELP node_vmstat_oom_kill /proc/vmstat information field oom_kill. |
2543 | # TYPE node_vmstat_oom_kill untyped | 2547 | # TYPE node_vmstat_oom_kill untyped |
2544 | node_vmstat_oom_kill 0 | 2548 | node_vmstat_oom_kill 0 |
diff --git a/collector/fixtures/sys.ttar b/collector/fixtures/sys.ttar index ee30c81..2880390 100644 --- a/collector/fixtures/sys.ttar +++ b/collector/fixtures/sys.ttar | |||
@@ -920,6 +920,12 @@ Lines: 1 | |||
920 | 1 | 920 | 1 |
921 | Mode: 644 | 921 | Mode: 644 |
922 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 922 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
923 | Directory: sys/class/thermal | ||
924 | Mode: 755 | ||
925 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
926 | Path: sys/class/thermal/thermal_zone0 | ||
927 | SymlinkTo: ../../devices/virtual/thermal/thermal_zone0 | ||
928 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
923 | Directory: sys/devices | 929 | Directory: sys/devices |
924 | Mode: 755 | 930 | Mode: 755 |
925 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 931 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
@@ -2460,6 +2466,30 @@ local_node 26719046550 | |||
2460 | other_node 9860526920 | 2466 | other_node 9860526920 |
2461 | Mode: 644 | 2467 | Mode: 644 |
2462 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 2468 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2469 | Directory: sys/devices/virtual | ||
2470 | Mode: 755 | ||
2471 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
2472 | Directory: sys/devices/virtual/thermal | ||
2473 | Mode: 755 | ||
2474 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
2475 | Directory: sys/devices/virtual/thermal/thermal_zone0 | ||
2476 | Mode: 755 | ||
2477 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
2478 | Path: sys/devices/virtual/thermal/thermal_zone0/policy | ||
2479 | Lines: 1 | ||
2480 | step_wise | ||
2481 | Mode: 644 | ||
2482 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
2483 | Path: sys/devices/virtual/thermal/thermal_zone0/temp | ||
2484 | Lines: 1 | ||
2485 | 12376 | ||
2486 | Mode: 644 | ||
2487 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
2488 | Path: sys/devices/virtual/thermal/thermal_zone0/type | ||
2489 | Lines: 1 | ||
2490 | cpu-thermal | ||
2491 | Mode: 644 | ||
2492 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
2463 | Directory: sys/fs | 2493 | Directory: sys/fs |
2464 | Mode: 755 | 2494 | Mode: 755 |
2465 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 2495 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
diff --git a/collector/thermal_zone_linux.go b/collector/thermal_zone_linux.go new file mode 100644 index 0000000..16fe61c --- /dev/null +++ b/collector/thermal_zone_linux.go | |||
@@ -0,0 +1,68 @@ | |||
1 | // Copyright 2019 The Prometheus Authors | ||
2 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
3 | // you may not use this file except in compliance with the License. | ||
4 | // You may obtain a copy of the License at | ||
5 | // | ||
6 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
7 | // | ||
8 | // Unless required by applicable law or agreed to in writing, software | ||
9 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
11 | // See the License for the specific language governing permissions and | ||
12 | // limitations under the License. | ||
13 | |||
14 | // +build !nothermalzone | ||
15 | |||
16 | package collector | ||
17 | |||
18 | import ( | ||
19 | "fmt" | ||
20 | |||
21 | "github.com/prometheus/client_golang/prometheus" | ||
22 | "github.com/prometheus/procfs/sysfs" | ||
23 | ) | ||
24 | |||
25 | type thermalZoneCollector struct { | ||
26 | fs sysfs.FS | ||
27 | zoneTemp *prometheus.Desc | ||
28 | } | ||
29 | |||
30 | func init() { | ||
31 | registerCollector("thermal_zone", defaultEnabled, NewThermalZoneCollector) | ||
32 | } | ||
33 | |||
34 | // NewThermalZoneCollector returns a new Collector exposing kernel/system statistics. | ||
35 | func NewThermalZoneCollector() (Collector, error) { | ||
36 | fs, err := sysfs.NewFS(*sysPath) | ||
37 | if err != nil { | ||
38 | return nil, fmt.Errorf("failed to open sysfs: %v", err) | ||
39 | } | ||
40 | |||
41 | return &thermalZoneCollector{ | ||
42 | fs: fs, | ||
43 | zoneTemp: prometheus.NewDesc( | ||
44 | prometheus.BuildFQName(namespace, "thermal_zone", "temp"), | ||
45 | "Zone temperature in Celsius", | ||
46 | []string{"zone", "type"}, nil, | ||
47 | ), | ||
48 | }, nil | ||
49 | } | ||
50 | |||
51 | func (c *thermalZoneCollector) Update(ch chan<- prometheus.Metric) error { | ||
52 | thermalZones, err := c.fs.ClassThermalZoneStats() | ||
53 | if err != nil { | ||
54 | return err | ||
55 | } | ||
56 | |||
57 | for _, stats := range thermalZones { | ||
58 | ch <- prometheus.MustNewConstMetric( | ||
59 | c.zoneTemp, | ||
60 | prometheus.GaugeValue, | ||
61 | float64(stats.Temp)/1000.0, | ||
62 | stats.Name, | ||
63 | stats.Type, | ||
64 | ) | ||
65 | } | ||
66 | |||
67 | return nil | ||
68 | } | ||
diff --git a/end-to-end-test.sh b/end-to-end-test.sh index 56ed04c..469b811 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh | |||
@@ -33,6 +33,7 @@ enabled_collectors=$(cat << COLLECTORS | |||
33 | schedstat | 33 | schedstat |
34 | sockstat | 34 | sockstat |
35 | stat | 35 | stat |
36 | thermal_zone | ||
36 | textfile | 37 | textfile |
37 | bonding | 38 | bonding |
38 | vmstat | 39 | vmstat |