diff options
author | Ralf Horstmann <ralf+github@ackstorm.de> | 2018-10-02 10:21:30 +0200 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2018-10-02 10:21:30 +0200 |
commit | 9f820bd3eee287f9124a5c3e66296ec03105be9d (patch) | |
tree | f90832e2c78489525e5b1e2c1807638aa7daf491 | |
parent | 5a461d261c99ed9479e491c97cfd3bfe310a4139 (diff) | |
download | prometheus_node_collector-9f820bd3eee287f9124a5c3e66296ec03105be9d.tar.bz2 prometheus_node_collector-9f820bd3eee287f9124a5c3e66296ec03105be9d.tar.xz prometheus_node_collector-9f820bd3eee287f9124a5c3e66296ec03105be9d.zip |
Update cpu collector for OpenBSD 6.4 (#1094)
Starting with (not yet released) OpenBSD 6.4, sysctl KERN_CPTIME2 will
return ENODEV for offline CPUs.
SMT siblings are reported as offline when hw.smt is disabled, which is
the default since one of the later Spectre variants. So this might
affect a few systems.
For more details see:
https://cvsweb.openbsd.org/src/sys/kern/kern_sysctl.c#rev1.348
Signed-off-by: Ralf Horstmann <ralf+github@ackstorm.de>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | collector/cpu_openbsd.go | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e02195f..7c99743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -24,6 +24,7 @@ Darwin meminfo metrics have been renamed to match Prometheus conventions. #1060 | |||
24 | * [BUGFIX] Handle vanishing PIDs #1043 | 24 | * [BUGFIX] Handle vanishing PIDs #1043 |
25 | * [BUGFIX] Correctly cast Darwin memory info #1060 | 25 | * [BUGFIX] Correctly cast Darwin memory info #1060 |
26 | * [BUGFIX] Filter systemd units in Go for compatibility with older versions #1083 | 26 | * [BUGFIX] Filter systemd units in Go for compatibility with older versions #1083 |
27 | * [BUGFIX] Update cpu collector for OpenBSD 6.4 | ||
27 | 28 | ||
28 | ## 0.16.0 / 2018-05-15 | 29 | ## 0.16.0 / 2018-05-15 |
29 | 30 | ||
diff --git a/collector/cpu_openbsd.go b/collector/cpu_openbsd.go index e9b102f..996e50e 100644 --- a/collector/cpu_openbsd.go +++ b/collector/cpu_openbsd.go | |||
@@ -59,10 +59,12 @@ func (c *cpuCollector) Update(ch chan<- prometheus.Metric) (err error) { | |||
59 | var cp_time [][C.CPUSTATES]C.int64_t | 59 | var cp_time [][C.CPUSTATES]C.int64_t |
60 | for i := 0; i < int(ncpus); i++ { | 60 | for i := 0; i < int(ncpus); i++ { |
61 | cp_timeb, err := unix.SysctlRaw("kern.cp_time2", i) | 61 | cp_timeb, err := unix.SysctlRaw("kern.cp_time2", i) |
62 | if err != nil { | 62 | if err != nil && err != unix.ENODEV { |
63 | return err | 63 | return err |
64 | } | 64 | } |
65 | cp_time = append(cp_time, *(*[C.CPUSTATES]C.int64_t)(unsafe.Pointer(&cp_timeb[0]))) | 65 | if err != unix.ENODEV { |
66 | cp_time = append(cp_time, *(*[C.CPUSTATES]C.int64_t)(unsafe.Pointer(&cp_timeb[0]))) | ||
67 | } | ||
66 | } | 68 | } |
67 | 69 | ||
68 | for cpu, time := range cp_time { | 70 | for cpu, time := range cp_time { |