pgnodemx
pgnodemx
pgnodemx : Capture node OS metrics via SQL queries
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6440 | pgnodemx
|
pgnodemx
|
1.7 |
STAT
|
Apache-2.0
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd-r
|
No
|
Yes
|
Yes
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | system_stats
pg_wait_sampling
pgsentinel
pgmeminfo
pgfincore
prioritize
pg_buffercache
|
| Siblings | pg_proctab
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
1.7 |
18
17
16
15
14
|
pgnodemx |
- |
| RPM | PIGSTY
|
1.7 |
18
17
16
15
14
|
pgnodemx_$v |
- |
| DEB | PIGSTY
|
1.7 |
18
17
16
15
14
|
postgresql-$v-pgnodemx |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
el8.aarch64
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
el9.x86_64
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
el9.aarch64
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
el10.x86_64
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
el10.aarch64
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
PIGSTY 1.7
|
d12.x86_64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
d12.aarch64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
d13.x86_64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
d13.aarch64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
u22.x86_64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
u22.aarch64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
u24.x86_64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
u24.aarch64
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
PGDG 2.0.1
|
Source
pig build pkg pgnodemx; # build rpm/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 pgnodemx; # install via package name, for the active PG version
pig install pgnodemx -v 18; # install for PG 18
pig install pgnodemx -v 17; # install for PG 17
pig install pgnodemx -v 16; # install for PG 16
pig install pgnodemx -v 15; # install for PG 15
pig install pgnodemx -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pgnodemx';Create this extension with:
CREATE EXTENSION pgnodemx;Usage
pgnodemx: SQL functions to access node OS metrics from PostgreSQL
pgnodemx provides SQL access to OS-level metrics including cgroup statistics, /proc filesystem data, and system information. Requires pg_monitor role membership.
cgroup Functions
-- Check cgroup support status
SELECT current_setting('pgnodemx.cgroup_enabled');
SELECT cgroup_mode(); -- 'legacy', 'unified', 'hybrid', or 'disabled'
-- Read cgroup scalar values
SELECT cgroup_scalar_bigint('memory.current');
SELECT cgroup_scalar_float8('cpu.uclamp.max');
SELECT cgroup_scalar_text('cgroup.type');
-- Read cgroup key-value files
SELECT * FROM cgroup_setof_kv('memory.stat');
SELECT * FROM cgroup_setof_kv('cpu.stat');
-- Read cgroup nested key-value files
SELECT * FROM cgroup_setof_nkv('memory.pressure');
SELECT * FROM cgroup_setof_nkv('cpu.pressure');
-- Get cgroup paths and process count
SELECT * FROM cgroup_path();
SELECT cgroup_process_count();/proc Functions
SELECT * FROM proc_diskstats(); -- /proc/diskstats
SELECT * FROM proc_mountinfo(); -- /proc/self/mountinfo
SELECT * FROM proc_meminfo(); -- /proc/meminfo
SELECT * FROM proc_network_stats(); -- /proc/self/net/dev
SELECT * FROM proc_pid_io(); -- /proc/<pid>/io for all PG processes
SELECT * FROM proc_pid_cmdline(); -- command line for all PG processes
SELECT * FROM proc_pid_stat(); -- /proc/<pid>/stat for all PG processes
SELECT * FROM proc_cputime(); -- first line of /proc/stat
SELECT * FROM proc_loadavg(); -- /proc/loadavgSystem Information
SELECT * FROM fsinfo('/pgdata'); -- filesystem info for a path
SELECT fips_mode(); -- OpenSSL FIPS mode status
SELECT openssl_version(); -- OpenSSL version
SELECT exec_path(); -- current PostgreSQL executable path
SELECT kpages_to_bytes(1024); -- convert kernel pages to bytes
SELECT * FROM stat_file('/path'); -- file uid, gid, mode infoEnvironment Variables
SELECT envvar_text('PGDATA');
SELECT envvar_bigint('PGPORT');Kubernetes DownwardAPI
SELECT * FROM kdapi_setof_kv('labels');
SELECT kdapi_scalar_bigint('cpu_limit');Configuration
| Parameter | Default | Description |
|---|---|---|
pgnodemx.cgroup_enabled |
on |
Enable cgroup functions |
pgnodemx.containerized |
off |
Force containerized cgroup paths |
pgnodemx.cgrouproot |
/sys/fs/cgroup |
cgroup mount location |
pgnodemx.kdapi_enabled |
on |
Enable Kubernetes DownwardAPI |
pgnodemx.kdapi_path |
/etc/podinfo |
DownwardAPI files location |
Last updated on