system_stats
system_stats
system_stats : EnterpriseDB system statistics for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6420 | system_stats | system_stats | 3.2 | STAT | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | pgnodemx pg_proctab pgmeminfo pgfincore pg_wait_sampling pg_buffercache pg_background pg_cooldown |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 3.2 | 18 17 16 15 14 | system_stats | - |
| RPM | PGDG | 3.2 | 18 17 16 15 14 | system_stats_$v | - |
| DEB | PIGSTY | 3.2 | 18 17 16 15 14 | postgresql-$v-system-stats | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PGDG 3.2 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 |
el8.aarch64 | PGDG 3.2 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 |
el9.x86_64 | PGDG 3.2 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 |
el9.aarch64 | PGDG 3.2 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 | PGDG 3.2.1 |
el10.x86_64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
el10.aarch64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
d12.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
d12.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
d13.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
d13.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
u22.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
u22.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
u24.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
u24.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
Source
pig build pkg system_stats; # build debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install system_stats; # install via package name, for the active PG version
pig install system_stats -v 18; # install for PG 18
pig install system_stats -v 17; # install for PG 17
pig install system_stats -v 16; # install for PG 16
pig install system_stats -v 15; # install for PG 15
pig install system_stats -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION system_stats;Usage
system_stats provides SQL functions to access OS-level statistics for monitoring. Supports Linux, macOS, and Windows.
Functions
-- Operating system info (name, version, hostname, uptime, etc.)
SELECT * FROM pg_sys_os_info();
-- CPU info (vendor, model, cores, clock speed, cache sizes)
SELECT * FROM pg_sys_cpu_info();
-- CPU usage (user, system, idle, iowait percentages)
SELECT * FROM pg_sys_cpu_usage_info();
-- Memory info (total, used, free, swap, cache in bytes)
SELECT * FROM pg_sys_memory_info();
-- Disk I/O analysis (reads, writes, bytes, time per device)
SELECT * FROM pg_sys_io_analysis_info();
-- Disk info (filesystem, mount point, total/used/available space)
SELECT * FROM pg_sys_disk_info();
-- Load average (1, 5, 10, 15 minute intervals)
SELECT * FROM pg_sys_load_avg_info();
-- Process info (total, running, sleeping, stopped, zombie counts)
SELECT * FROM pg_sys_process_info();
-- Network info (interface, IP, bytes/packets sent/received, errors)
SELECT * FROM pg_sys_network_info();
-- Per-process CPU and memory usage
SELECT * FROM pg_sys_cpu_memory_by_process();Security
Access is restricted to superusers and members of the monitor_system_stats role:
-- Grant access to a monitoring user
GRANT monitor_system_stats TO nagios;
-- Or grant per-function to pg_monitor
GRANT EXECUTE ON FUNCTION pg_sys_os_info() TO pg_monitor;Example: System Overview
SELECT * FROM pg_sys_load_avg_info(); -- load averages
SELECT memfree, memused, swapfree FROM pg_sys_memory_info(); -- memory
SELECT * FROM pg_sys_cpu_usage_info(); -- CPU usage breakdownLast updated on