From 153947705e52b0dd13f6a3168a7269d553b02524 Mon Sep 17 00:00:00 2001 From: Matt Oshry <55526879+splmatto@users.noreply.github.com> Date: Mon, 29 Nov 2021 01:55:36 -0800 Subject: [PATCH 1/4] Handle nil CPU thermal power status on M1 (#2225) Signed-off-by: Matt Oshry --- CHANGELOG.md | 2 ++ collector/thermal_darwin.go | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 675057ec..a152600b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * [ENHANCEMENT] * [BUGFIX] +* [BUGFIX] Handle nil CPU thermal power status on M1 #2218 + ## 1.3.0 / 2021-10-20 NOTE: In order to support globs in the textfile collector path, filenames exposed by diff --git a/collector/thermal_darwin.go b/collector/thermal_darwin.go index 282ca3f3..25673dcc 100644 --- a/collector/thermal_darwin.go +++ b/collector/thermal_darwin.go @@ -47,9 +47,10 @@ import "C" import ( "errors" "fmt" + "unsafe" + "github.com/go-kit/log" "github.com/prometheus/client_golang/prometheus" - "unsafe" ) type thermCollector struct { @@ -118,7 +119,9 @@ func (c *thermCollector) Update(ch chan<- prometheus.Metric) error { func fetchCPUPowerStatus() (map[string]int, error) { cfDictRef, _ := C.FetchThermal() defer func() { - C.CFRelease(C.CFTypeRef(cfDictRef.ref)) + if cfDictRef.ref != 0x0 { + C.CFRelease(C.CFTypeRef(cfDictRef.ref)) + } }() if C.kIOReturnNotFound == cfDictRef.ret { From 6af0c6306a479cab9a540b341b1888683f8a01c8 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Wed, 1 Dec 2021 11:13:43 +0100 Subject: [PATCH 2/4] Sanitize UTF-8 in dmi collector (#2229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace invalid UTF-8 chars with "�" string. Fixes: https://github.com/prometheus/node_exporter/issues/2228 Signed-off-by: Ben Kochie --- CHANGELOG.md | 2 ++ collector/dmi.go | 3 ++- collector/fixtures/e2e-output.txt | 2 +- collector/fixtures/sys.ttar | 2 +- end-to-end-test.sh | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a152600b..026d4630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ * [ENHANCEMENT] * [BUGFIX] +* [ENHANCEMENT] Add node_softirqs_total metric #2221 * [BUGFIX] Handle nil CPU thermal power status on M1 #2218 +* [BUGFIX] Sanitize UTF-8 in dmi collector #2229 ## 1.3.0 / 2021-10-20 diff --git a/collector/dmi.go b/collector/dmi.go index 3cc2a8a5..79475507 100644 --- a/collector/dmi.go +++ b/collector/dmi.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "os" + "strings" "github.com/go-kit/log" "github.com/go-kit/log/level" @@ -78,7 +79,7 @@ func NewDMICollector(logger log.Logger) (Collector, error) { } { if value != nil { labels = append(labels, label) - values = append(values, *value) + values = append(values, strings.ToValidUTF8(*value, "�")) } } diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 779eb3b6..4a61538c 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -609,7 +609,7 @@ node_disk_written_bytes_total{device="sr0"} 0 node_disk_written_bytes_total{device="vda"} 1.0938236928e+11 # HELP node_dmi_info A metric with a constant '1' value labeled by bios_date, bios_release, bios_vendor, bios_version, board_asset_tag, board_name, board_serial, board_vendor, board_version, chassis_asset_tag, chassis_serial, chassis_vendor, chassis_version, product_family, product_name, product_serial, product_sku, product_uuid, product_version, system_vendor if provided by DMI. # TYPE node_dmi_info gauge -node_dmi_info{bios_date="04/12/2021",bios_release="2.2",bios_vendor="Dell Inc.",bios_version="2.2.4",board_name="07PXPY",board_serial=".7N62AI2.GRTCL6944100GP.",board_vendor="Dell Inc.",board_version="A01",chassis_asset_tag="",chassis_serial="7N62AI2",chassis_vendor="Dell Inc.",chassis_version="",product_family="PowerEdge",product_name="PowerEdge R6515",product_serial="7N62AI2",product_sku="SKU=NotProvided;ModelName=PowerEdge R6515",product_uuid="83340ca8-cb49-4474-8c29-d2088ca84dd9",product_version="",system_vendor="Dell Inc."} 1 +node_dmi_info{bios_date="04/12/2021",bios_release="2.2",bios_vendor="Dell Inc.",bios_version="2.2.4",board_name="07PXPY",board_serial=".7N62AI2.GRTCL6944100GP.",board_vendor="Dell Inc.",board_version="A01",chassis_asset_tag="",chassis_serial="7N62AI2",chassis_vendor="Dell Inc.",chassis_version="",product_family="PowerEdge",product_name="PowerEdge R6515",product_serial="7N62AI2",product_sku="SKU=NotProvided;ModelName=PowerEdge R6515",product_uuid="83340ca8-cb49-4474-8c29-d2088ca84dd9",product_version="�[�",system_vendor="Dell Inc."} 1 # HELP node_drbd_activitylog_writes_total Number of updates of the activity log area of the meta data. # TYPE node_drbd_activitylog_writes_total counter node_drbd_activitylog_writes_total{device="drbd1"} 1100 diff --git a/collector/fixtures/sys.ttar b/collector/fixtures/sys.ttar index a08e6b61..72a97b41 100644 --- a/collector/fixtures/sys.ttar +++ b/collector/fixtures/sys.ttar @@ -141,7 +141,7 @@ Mode: 400 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Path: sys/class/dmi/id/product_version Lines: 1 - +À[‡ Mode: 444 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Path: sys/class/dmi/id/sys_vendor diff --git a/end-to-end-test.sh b/end-to-end-test.sh index f024890d..0455d763 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -11,6 +11,7 @@ enabled_collectors=$(cat << COLLECTORS cpu cpufreq diskstats + dmi drbd edac entropy From 8433364845aabac5aa4052047d39fd6f7996cf93 Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Wed, 1 Dec 2021 11:21:31 +0100 Subject: [PATCH 3/4] Ignore filesystems flagged as MNT_IGNORE. (#2227) * Ignore filesystems flagges as MNT_IGNORE. Closes #2152. Signed-off-by: Lapo Luchini --- collector/filesystem_freebsd.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/collector/filesystem_freebsd.go b/collector/filesystem_freebsd.go index 768eb797..25ba20a4 100644 --- a/collector/filesystem_freebsd.go +++ b/collector/filesystem_freebsd.go @@ -24,18 +24,16 @@ import ( const ( defMountPointsExcluded = "^/(dev)($|/)" defFSTypesExcluded = "^devfs$" - readOnly = 0x1 // MNT_RDONLY - noWait = 0x2 // MNT_NOWAIT ) // Expose filesystem fullness. func (c *filesystemCollector) GetStats() ([]filesystemStats, error) { - n, err := unix.Getfsstat(nil, noWait) + n, err := unix.Getfsstat(nil, unix.MNT_NOWAIT) if err != nil { return nil, err } buf := make([]unix.Statfs_t, n) - _, err = unix.Getfsstat(buf, noWait) + _, err = unix.Getfsstat(buf, unix.MNT_NOWAIT) if err != nil { return nil, err } @@ -54,8 +52,13 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) { continue } + if (fs.Flags & unix.MNT_IGNORE) != 0 { + level.Debug(c.logger).Log("msg", "Ignoring mount flagged as ignore", "mountpoint", mountpoint) + continue + } + var ro float64 - if (fs.Flags & readOnly) != 0 { + if (fs.Flags & unix.MNT_RDONLY) != 0 { ro = 1 } From 6c5c3d1234794c42639c2eba408d4f667fcd5430 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sat, 4 Dec 2021 13:56:38 +0100 Subject: [PATCH 4/4] Release 1.3.1 (#2232) * [BUGFIX] Handle nil CPU thermal power status on M1 #2218 * [BUGFIX] bsd: Ignore filesystems flagged as MNT_IGNORE. #2227 * [BUGFIX] Sanitize UTF-8 in dmi collector #2229 Signed-off-by: Ben Kochie --- CHANGELOG.md | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 026d4630..8eff0f40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,11 @@ * [BUGFIX] * [ENHANCEMENT] Add node_softirqs_total metric #2221 + +## 1.3.1 / 2021-12-01 + * [BUGFIX] Handle nil CPU thermal power status on M1 #2218 +* [BUGFIX] bsd: Ignore filesystems flagged as MNT_IGNORE. #2227 * [BUGFIX] Sanitize UTF-8 in dmi collector #2229 ## 1.3.0 / 2021-10-20 diff --git a/VERSION b/VERSION index f0bb29e7..3a3cd8cc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.0 +1.3.1