Skip to content

Commit f2ec547

Browse files
SuperQtickez
andauthored
Release v1.9.1 (#3285)
* Avoid memory leak by using value rather than reference. (#3277) Signed-off-by: Rolf Klemenz <[email protected]> * pressure: Fix missing IRQ on older kernels (#3263) Fix "no data" error on kernels that support some PSI status, but don't yet have IRQ presure metrics. Only report "no data" error if `pressure` is enabled and no PSI metrics were found. Fixes: #3259 Signed-off-by: Ben Kochie <[email protected]> * Release v1.9.1 * [BUGFIX] pressure: Fix missing IRQ on older kernels #3263 * [BUGFIX] Fix Darwin memory leak #3277 Signed-off-by: Ben Kochie <[email protected]> --------- Signed-off-by: Rolf Klemenz <[email protected]> Signed-off-by: Ben Kochie <[email protected]> Co-authored-by: Rolf Klemenz <[email protected]>
1 parent 02afa5c commit f2ec547

File tree

7 files changed

+65
-43
lines changed

7 files changed

+65
-43
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
* [ENHANCEMENT]
66
* [BUGFIX]
77

8+
## 1.9.1 / 2025-04-01
9+
10+
* [BUGFIX] pressure: Fix missing IRQ on older kernels #3263
11+
* [BUGFIX] Fix Darwin memory leak #3277
12+
813
## 1.9.0 / 2025-02-17
914

1015
* [CHANGE] meminfo: Convert linux implementation to use procfs lib #3049

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.0
1+
1.9.1

collector/filesystem_common.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ type filesystemStats struct {
8989
labels filesystemLabels
9090
size, free, avail float64
9191
files, filesFree float64
92-
purgeable *float64
92+
purgeable float64
9393
ro, deviceError float64
9494
}
9595

@@ -232,11 +232,10 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) error {
232232
c.mountInfoDesc, prometheus.GaugeValue,
233233
1.0, s.labels.device, s.labels.major, s.labels.minor, s.labels.mountPoint,
234234
)
235-
if s.purgeable != nil {
235+
if s.purgeable >= 0 {
236236
ch <- prometheus.MustNewConstMetric(
237237
c.purgeableDesc, prometheus.GaugeValue,
238-
*s.purgeable, s.labels.device, s.labels.mountPoint,
239-
s.labels.fsType, s.labels.deviceError,
238+
s.purgeable, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
240239
)
241240
}
242241
}

collector/filesystem_macos.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,22 @@ package collector
2020
#cgo CFLAGS: -x objective-c
2121
#cgo LDFLAGS: -framework Foundation
2222
#import <Foundation/Foundation.h>
23-
Float64 *purgeable(char *path) {
23+
Float64 purgeable(char *path) {
2424
CFNumberRef tmp;
25-
Float64 *value;
2625
NSError *error = nil;
2726
NSString *str = [NSString stringWithUTF8String:path];
2827
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:str];
2928
NSDictionary *results = [fileURL resourceValuesForKeys:@[NSURLVolumeAvailableCapacityForImportantUsageKey] error:&error];
3029
if (results) {
31-
if ((tmp = CFDictionaryGetValue((CFDictionaryRef)results, NSURLVolumeAvailableCapacityForImportantUsageKey)) == NULL)
32-
return NULL;
33-
value = (Float64 *)malloc(sizeof(Float64));
34-
if (CFNumberGetValue(tmp, kCFNumberFloat64Type, value)) {
30+
if ((tmp = CFDictionaryGetValue((CFDictionaryRef)results, NSURLVolumeAvailableCapacityForImportantUsageKey)) == NULL) {
31+
return -1.0f;
32+
}
33+
Float64 value;
34+
if (CFNumberGetValue(tmp, kCFNumberFloat64Type, &value)) {
3535
return value;
3636
}
3737
}
38-
free(value);
39-
return NULL;
38+
return -1.0f;
4039
}
4140
*/
4241
import "C"
@@ -100,7 +99,7 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {
10099
avail: float64(mnt[i].f_bavail) * float64(mnt[i].f_bsize),
101100
files: float64(mnt[i].f_files),
102101
filesFree: float64(mnt[i].f_ffree),
103-
purgeable: (*float64)(C.purgeable(C.CString(mountpoint))),
102+
purgeable: float64(C.purgeable(C.CString(mountpoint))),
104103
ro: ro,
105104
})
106105
}

collector/pressure_linux.go

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ import (
2727
"github.com/prometheus/procfs"
2828
)
2929

30+
const (
31+
psiResourceCPU = "cpu"
32+
psiResourceIO = "io"
33+
psiResourceMemory = "memory"
34+
psiResourceIRQ = "irq"
35+
)
36+
3037
var (
31-
psiResources = []string{"cpu", "io", "memory", "irq"}
38+
psiResources = []string{psiResourceCPU, psiResourceIO, psiResourceMemory, psiResourceIRQ}
3239
)
3340

3441
type pressureStatsCollector struct {
@@ -93,13 +100,18 @@ func NewPressureStatsCollector(logger *slog.Logger) (Collector, error) {
93100

94101
// Update calls procfs.NewPSIStatsForResource for the different resources and updates the values
95102
func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
103+
foundResources := 0
96104
for _, res := range psiResources {
97105
c.logger.Debug("collecting statistics for resource", "resource", res)
98106
vals, err := c.fs.PSIStatsForResource(res)
99107
if err != nil {
100-
if errors.Is(err, os.ErrNotExist) {
101-
c.logger.Debug("pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
102-
return ErrNoData
108+
if errors.Is(err, os.ErrNotExist) && res != psiResourceIRQ {
109+
c.logger.Debug("pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel", "resource", res)
110+
continue
111+
}
112+
if errors.Is(err, os.ErrNotExist) && res == psiResourceIRQ {
113+
c.logger.Debug("IRQ pressure information is unavailable, you need a Linux kernel >= 6.1 and/or CONFIG_PSI enabled for your kernel", "resource", res)
114+
continue
103115
}
104116
if errors.Is(err, syscall.ENOTSUP) {
105117
c.logger.Debug("pressure information is disabled, add psi=1 kernel command line to enable it")
@@ -109,28 +121,35 @@ func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
109121
}
110122
// IRQ pressure does not have 'some' data.
111123
// See https://github.com/torvalds/linux/blob/v6.9/include/linux/psi_types.h#L65
112-
if vals.Some == nil && res != "irq" {
124+
if vals.Some == nil && res != psiResourceIRQ {
113125
c.logger.Debug("pressure information returned no 'some' data")
114126
return ErrNoData
115127
}
116-
if vals.Full == nil && res != "cpu" {
128+
if vals.Full == nil && res != psiResourceCPU {
117129
c.logger.Debug("pressure information returned no 'full' data")
118130
return ErrNoData
119131
}
120132
switch res {
121-
case "cpu":
133+
case psiResourceCPU:
122134
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, float64(vals.Some.Total)/1000.0/1000.0)
123-
case "io":
135+
case psiResourceIO:
124136
ch <- prometheus.MustNewConstMetric(c.io, prometheus.CounterValue, float64(vals.Some.Total)/1000.0/1000.0)
125137
ch <- prometheus.MustNewConstMetric(c.ioFull, prometheus.CounterValue, float64(vals.Full.Total)/1000.0/1000.0)
126-
case "memory":
138+
case psiResourceMemory:
127139
ch <- prometheus.MustNewConstMetric(c.mem, prometheus.CounterValue, float64(vals.Some.Total)/1000.0/1000.0)
128140
ch <- prometheus.MustNewConstMetric(c.memFull, prometheus.CounterValue, float64(vals.Full.Total)/1000.0/1000.0)
129-
case "irq":
141+
case psiResourceIRQ:
130142
ch <- prometheus.MustNewConstMetric(c.irqFull, prometheus.CounterValue, float64(vals.Full.Total)/1000.0/1000.0)
131143
default:
132144
c.logger.Debug("did not account for resource", "resource", res)
145+
continue
133146
}
147+
foundResources++
148+
}
149+
150+
if foundResources == 0 {
151+
c.logger.Debug("pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
152+
return ErrNoData
134153
}
135154

136155
return nil

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/prometheus/node_exporter
22

3-
go 1.22.0
3+
go 1.23.0
44

55
require (
66
github.com/alecthomas/kingpin/v2 v2.4.0
@@ -29,7 +29,7 @@ require (
2929
github.com/prometheus/procfs v0.15.2-0.20240603130017-1754b780536b // == v0.15.1 + https://github.com/prometheus/procfs/commit/1754b780536bb81082baa913e04cc4fff4d2baea
3030
github.com/safchain/ethtool v0.5.10
3131
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
32-
golang.org/x/sys v0.30.0
32+
golang.org/x/sys v0.31.0
3333
howett.net/plist v1.0.1
3434
)
3535

@@ -51,11 +51,11 @@ require (
5151
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
5252
go.uber.org/atomic v1.7.0 // indirect
5353
go.uber.org/multierr v1.6.0 // indirect
54-
golang.org/x/crypto v0.32.0 // indirect
55-
golang.org/x/net v0.33.0 // indirect
56-
golang.org/x/oauth2 v0.24.0 // indirect
57-
golang.org/x/sync v0.10.0 // indirect
58-
golang.org/x/text v0.21.0 // indirect
54+
golang.org/x/crypto v0.36.0 // indirect
55+
golang.org/x/net v0.37.0 // indirect
56+
golang.org/x/oauth2 v0.28.0 // indirect
57+
golang.org/x/sync v0.12.0 // indirect
58+
golang.org/x/text v0.23.0 // indirect
5959
google.golang.org/protobuf v1.36.1 // indirect
6060
gopkg.in/yaml.v2 v2.4.0 // indirect
6161
)

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,23 @@ go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
102102
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
103103
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
104104
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
105-
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
106-
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
105+
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
106+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
107107
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
108108
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
109-
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
110-
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
111-
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
112-
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
113-
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
114-
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
109+
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
110+
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
111+
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
112+
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
113+
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
114+
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
115115
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
116116
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
117117
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
118-
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
119-
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
120-
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
121-
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
118+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
119+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
120+
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
121+
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
122122
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
123123
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
124124
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)