Documentation
¶
Overview ¶
Package sysmem reports machine memory.
It reads /proc/meminfo on Linux and reports "unknown" elsewhere, so callers must handle absence rather than assume a number. Needs no cgroup, no systemd, and no privileges — which is why it still works on Termux/Android, where scope isolation does not.
Index ¶
Constants ¶
const ( PressureOK = "ok" PressureWarn = "warn" PressureFull = "full" )
Pressure levels for the UI.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DiskUsage ¶ added in v0.39.2
DiskUsage is the capacity of the filesystem holding one path.
Available is what a NON-ROOT process may actually use, which is smaller than Free on most filesystems: ext4 reserves a percentage for root. Reporting Free would tell an unprivileged wick it has room it cannot take.
func Disk ¶ added in v0.39.2
Disk reports the capacity of the filesystem holding path.
ok is false when the path cannot be stat'd — a relocated data dir that does not exist yet, or a platform without statfs. Callers must render "unknown" rather than a zeroed row, or an unreadable disk looks like an empty one.
func (DiskUsage) Pressure ¶ added in v0.39.2
Pressure grades how close this filesystem is to causing failures.
Percentage ALONE is the wrong signal, and gets it wrong in both directions. A 328 GB laptop disk at 93% still has 22 GB free — nothing is about to fail — while a 20 GB volume at 89% has 2 GB left and very nearly is. Judging by absolute free alone is equally wrong: 5 GB left on a 6 TB array means something quite different from 5 GB on a 10 GB volume.
So both must agree before the UI cries wolf: a level is only reached when the disk is BOTH proportionally full AND short of room in absolute terms. An alarm that fires on a healthy laptop is an alarm operators learn to ignore.