pg_stat_sysinfo
pg_stat_sysinfo · Query host load, CPU, memory, swap, and disk statistics from PostgreSQL, with optional shared-memory caching.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100803 | pg_stat_sysinfo | pg_stat_sysinfo | 0.0.1 | STAT | MIT | Rust |
PostgreSQL · 14, 15
Usage
Sources:
- Project README
- Extension control file
- Package metadata
- SQL functions and view
- Collector implementation
- Background cache worker
pg_stat_sysinfo 0.0.1 is a pgrx system-metrics prototype. It reports load averages, CPU use, memory and swap capacity and use, and mounted-disk capacity. pg_stat_sysinfo_collect() samples synchronously; an optional background worker stores recent samples in a shared-memory ring buffer exposed through the pg_stat_sysinfo view.
Direct and cached collection
Direct collection does not require preloading:
For cached collection, configure the library and interval, then restart PostgreSQL:
The fixed cache is about 1280 KiB, so retention varies with the number of filesystems and collection interval. A configuration reload can change the interval and periodically refresh the disk list.
Visibility, overhead, and compatibility
Metrics reveal host load, memory, swap, filesystem mount names, and capacities. Review default function execution privileges and grant access only to monitoring roles. Direct calls refresh operating-system counters and may briefly wait for the system library’s minimum CPU sampling interval; aggressive polling adds backend and filesystem-enumeration work.
The reviewed Cargo features cover PostgreSQL 11 through 15 with pgrx 0.8.3, and the last code change is from 2023. There is no evidence for current majors or containers with unusual mount namespaces. Values are point-in-time host observations, not PostgreSQL attribution and not durable monitoring. Validate units, cgroup visibility, disk discovery, failover behavior, and sampling overhead, then export important metrics to a maintained monitoring system.