Skip to content

Conversation

@ledeuns
Copy link
Contributor

@ledeuns ledeuns commented Dec 14, 2024

Purgeable space is space that macOS can free up when needed by removing files from your computer (you can't manually remove the files that are designated purgeable, but macOS removes them as space is required). So statfs can report low available space when in fact you can use more than that.

Tested on MacOS 14 (x86+M2) and Ubuntu 22.04
Needs to be started as root to get purgeable space info (otherwise it returns 0)

@discordianfish
Copy link
Member

Needs to be started as root to get purgeable space info (otherwise it returns 0)

We don't support metrics that require root: https://github.com/prometheus/node_exporter/blob/master/CONTRIBUTING.md#collector-implementation-guidelines
If you find another way, that doesn't require root, I'm happy to revisit this because this does seem helpful

@ledeuns
Copy link
Contributor Author

ledeuns commented Dec 23, 2024

I remove that comment, it came from an older version of the diff 😉 Running the node_exporter with a regular user on my test machines report available space correctly.

@discordianfish discordianfish merged commit 963158d into prometheus:master Feb 2, 2025
7 checks passed
@discordianfish
Copy link
Member

Thanks!

SuperQ added a commit that referenced this pull request Feb 16, 2025
* [CHANGE] meminfo: Convert linux implementation to use procfs lib #3049
* [CHANGE] Update logging to use Go log/slog #3097
* [FEATURE] filesystem: Add `node_filesystem_mount_info` metric #2970
* [FEATURE] btrfs: Add metrics for commit statistics #3010
* [FEATURE] interrupts: Add collector include/exclude filtering #3028
* [FEATURE] interrupts: Add "exclude zeros" filtering #3028
* [FEATURE] slabinfo: Add filters for slab name. #3041
* [FEATURE] pressure: add IRQ PSI metrics #3048
* [FEATURE] hwmon: Add include and exclude filter for sensors #3072
* [FEATURE] filesystem: Add NetBSD support #3082
* [FEATURE] netdev: Add ifAlias label #3087
* [FEATURE] hwmon: Add Support for GPU Clock Frequencies #3093
* [FEATURE] Add `exclude[]` URL parameter #3116
* [FEATURE] Add AIX support #3136
* [FEATURE] filesystem: Add fs-types/mount-points include flags #3171
* [FEATURE] netstat: Add collector for tcp packet counters for FreeBSD. #3177
* [ENHANCEMENT] ethtool: Add logging for filtering flags #2979
* [ENHANCEMENT] netstat: Add TCPRcvQDrop to default metrics #3021
* [ENHANCEMENT] diskstats: Add block device rotational #3022
* [ENHANCEMENT] cpu: Support CPU online status #3032
* [ENHANCEMENT] arp: optimize interface name resolution #3133
* [ENHANCEMENT] textfile: Allow specifiying multiple directory globs #3135
* [ENHANCEMENT] filesystem: Add reporting of purgeable space on MacOS #3206
* [ENHANCEMENT] ethtool: Skip full scan of NetClass directories #3239
* [BUGFIX] zfs: Prevent `procfs` integer underflow #2961
* [BUGFIX] pressure: Fix collection on systems that do not expose a full CPU stat #3054
* [BUGFIX] cpu: Fix FreeBSD 32-bit host support and plug memory leak #3083
* [BUGFIX] hwmon: Add safety check to hwmon read #3134
* [BUGFIX] zfs: Allow space in dataset name #3186

Signed-off-by: Ben Kochie <[email protected]>
@SuperQ SuperQ mentioned this pull request Feb 16, 2025
SuperQ added a commit that referenced this pull request Feb 17, 2025
* [CHANGE] meminfo: Convert linux implementation to use procfs lib #3049
* [CHANGE] Update logging to use Go log/slog #3097
* [FEATURE] filesystem: Add `node_filesystem_mount_info` metric #2970
* [FEATURE] btrfs: Add metrics for commit statistics #3010
* [FEATURE] interrupts: Add collector include/exclude filtering #3028
* [FEATURE] interrupts: Add "exclude zeros" filtering #3028
* [FEATURE] slabinfo: Add filters for slab name. #3041
* [FEATURE] pressure: add IRQ PSI metrics #3048
* [FEATURE] hwmon: Add include and exclude filter for sensors #3072
* [FEATURE] filesystem: Add NetBSD support #3082
* [FEATURE] netdev: Add ifAlias label #3087
* [FEATURE] hwmon: Add Support for GPU Clock Frequencies #3093
* [FEATURE] Add `exclude[]` URL parameter #3116
* [FEATURE] Add AIX support #3136
* [FEATURE] filesystem: Add fs-types/mount-points include flags #3171
* [FEATURE] netstat: Add collector for tcp packet counters for FreeBSD. #3177
* [ENHANCEMENT] ethtool: Add logging for filtering flags #2979
* [ENHANCEMENT] netstat: Add TCPRcvQDrop to default metrics #3021
* [ENHANCEMENT] diskstats: Add block device rotational #3022
* [ENHANCEMENT] cpu: Support CPU online status #3032
* [ENHANCEMENT] arp: optimize interface name resolution #3133
* [ENHANCEMENT] textfile: Allow specifiying multiple directory globs #3135
* [ENHANCEMENT] filesystem: Add reporting of purgeable space on MacOS #3206
* [ENHANCEMENT] ethtool: Skip full scan of NetClass directories #3239
* [BUGFIX] zfs: Prevent `procfs` integer underflow #2961
* [BUGFIX] pressure: Fix collection on systems that do not expose a full CPU stat #3054
* [BUGFIX] cpu: Fix FreeBSD 32-bit host support and plug memory leak #3083
* [BUGFIX] hwmon: Add safety check to hwmon read #3134
* [BUGFIX] zfs: Allow space in dataset name #3186

Signed-off-by: Ben Kochie <[email protected]>
@tickez
Copy link
Contributor

tickez commented Mar 14, 2025

It appears that this feature creates an issue with latest MacOS 15.3.2.
I get segmentation faults both in Intel and Apple Silicon Macs. Runs fine with 15.3
Disabling the filesystem collector resolves the crash.

SIGSEGV: segmentation violation
PC=0x19af21ff8 m=0 sigcode=2 addr=0x0
signal arrived during cgo execution

goroutine 63 gp=0x14000093c00 m=0 mp=0x100da2a80 [syscall]:
runtime.cgocall(0x1006c37c0, 0x1400017b418)
	runtime/cgocall.go:167 +0x44 fp=0x1400017b3e0 sp=0x1400017b3a0 pc=0x1001a0e34
github.com/prometheus/node_exporter/collector._Cfunc_purgeable(0x600001d54f00)
	_cgo_gotypes.go:731 +0x34 fp=0x1400017b410 sp=0x1400017b3e0 pc=0x1006708b4
github.com/prometheus/node_exporter/collector.(*filesystemCollector).GetStats(0x1400023bdc0)
	github.com/prometheus/node_exporter/collector/filesystem_macos.go:103 +0x338 fp=0x1400017b630 sp=0x1400017b410 pc=0x1006713a8
github.com/prometheus/node_exporter/collector.(*filesystemCollector).Update(0x1400023bdc0, 0x1400011f810)
	github.com/prometheus/node_exporter/collector/filesystem_common.go:186 +0x2c fp=0x1400017bd90 sp=0x1400017b630 pc=0x10066526c
github.com/prometheus/node_exporter/collector.execute({0x1006cbc7d, 0xa}, {0x100928dc0, 0x1400023bdc0}, 0x1400011f810, 0x1400011c430)
	github.com/prometheus/node_exporter/collector/collector.go:160 +0x60 fp=0x1400017bf50 sp=0x1400017bd90 pc=0x100663920
github.com/prometheus/node_exporter/collector.NodeCollector.Collect.func1({0x1006cbc7d?, 0x0?}, {0x100928dc0?, 0x1400023bdc0?})
	github.com/prometheus/node_exporter/collector/collector.go:151 +0x38 fp=0x1400017bfa0 sp=0x1400017bf50 pc=0x100663888
github.com/prometheus/node_exporter/collector.NodeCollector.Collect.gowrap1()
	github.com/prometheus/node_exporter/collector/collector.go:153 +0x3c fp=0x1400017bfd0 sp=0x1400017bfa0 pc=0x10066381c
runtime.goexit({})
	runtime/asm_arm64.s:1223 +0x4 fp=0x1400017bfd0 sp=0x1400017bfd0 pc=0x1001abf54
created by github.com/prometheus/node_exporter/collector.NodeCollector.Collect in goroutine 56
	github.com/prometheus/node_exporter/collector/collector.go:150 +0xac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants