Skip to content

pg_proctab

PostgreSQL extension to access the OS process table

pgnodemx · PostgreSQL extension to access the OS process table

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
6460pg_proctabpgnodemx2.0.1STATApache-2.0SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d-rNoNoNoYesyesno
Relationships
Requirespgnodemx
See Alsosystem_stats pg_stat_kcache pgmeminfo
Siblingspgnodemx
pgnodemx compatibility module. PGXN lists legacy pg_proctab. Partial PGDG RPM coverage.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY2.0.119 18 17 16 15pgnodemxpgnodemx
RPMPIGSTY2.0.119 18 17 16 15pgnodemx_$v-
DEBPGDG2.0.119 18 17 16 15postgresql-$v-pgnodemx-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
el8.aarch64N/APGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
el9.x86_64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
el9.aarch64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
el10.x86_64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
el10.aarch64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
d12.x86_64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
d12.aarch64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
d13.x86_64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
d13.aarch64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
u22.x86_64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
u22.aarch64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
u24.x86_64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
u24.aarch64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
u26.x86_64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1
u26.aarch64PIGSTY 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1PGDG 2.0.1

Source

pig build pkg pgnodemx;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgnodemx;		# install by package name
pig install pg_proctab;		# install by extension name

pig install pg_proctab -v 19;   # install for PG 19
pig install pg_proctab -v 18;   # install for PG 18
pig install pg_proctab -v 17;   # install for PG 17
pig install pg_proctab -v 16;   # install for PG 16
pig install pg_proctab -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_proctab CASCADE; -- requires pgnodemx

Usage

Sources:

The pg_proctab shipped in pgnodemx provides five SQL wrappers for the legacy process-monitoring interface. It depends on pgnodemx; the package version is 2.0.1, while its SQL installation version is 0.0.10-compat.

Enable

Add pgnodemx to shared_preload_libraries, preserving other entries, then restart PostgreSQL:

shared_preload_libraries = 'pgnodemx'

Install both extensions in the same schema as a superuser:

CREATE EXTENSION pgnodemx;
CREATE EXTENSION pg_proctab VERSION '0.0.10-compat';

The explicit version is required because the main control file has no default version. The audited PGDG RPM packages omit that main control file; use a package containing it before running this command. Querying the underlying OS metrics requires superuser privileges or membership in pg_monitor.

Query

SELECT a.pid, a.query, p.utime, p.stime, p.vsize, p.rss
FROM pg_stat_activity a
JOIN pg_proctab() p ON a.pid = p.pid;

SELECT "user", nice, system, idle, iowait FROM pg_cputime();
SELECT load1, load5, load15, last_pid FROM pg_loadavg();
SELECT memused, memfree, memshared, membuffers, memcached,
       swapused, swapfree, swapcached
FROM pg_memusage();
SELECT devname, reads_completed, writes_completed,
       sectors_read, sectors_written
FROM pg_diskusage();

These functions read Linux process and system statistics visible to the PostgreSQL server. Container namespaces and OS permissions affect what is visible. In this compatibility layer, rss is reported in KiB, memory totals in MiB, and memshared comes from Shmem.

Table reader