pgmon-0.3.0 is not a library.
pgmon
A PostgreSQL monitoring TUI inspired by pg_activity.
Features
- Real-time views of:
pg_stat_activitypg_stat_replication/pg_replication_slotspg_stat_databasepg_lockspg_stat_io(PostgreSQL 16+)pg_stat_statements(if extension exists)
- Pg-activity-inspired
Activitydashboard with sampled TPS/DML/temp rates, session counts, and worker/process summaries - Activity subviews for active, waiting, blocking, and idle in transaction backends
- Interactive TUI (Tabs, Table navigation)
- Configurable refresh rate and top-N rows.
Installation
Usage
# Specific home view and sort
# Fail faster on unreachable hosts
# Save selected queries into a persistent directory
# Or rely on PGMON_DSN / ~/.pgpass
PGMON_DSN="postgresql://postgres@localhost/postgres"
CLI Options
-d, --dsn <STRING>: PostgreSQL connection string (optional ifPGMON_DSNor.pgpassis available)--connect-timeout-ms <u64>: Connection timeout in milliseconds (default: 3000)--query-output-dir <PATH>: Directory used when saving selected queries withEnter-r, --refresh-ms <u64>: Refresh interval (default: 1000)-n, --top-n <u32>: Rows to show (default: 10)--home-view <activity|statements>: Initial view-s, --sort <total_time|mean_time|calls>: Statements sort column (default:total_time)-v: Verbose logging
If no DSN is provided, pgmon falls back to PGMON_DSN and then to the first usable entry in PGPASSFILE or ~/.pgpass.
In the Database view, press Enter on a selected database row to browse schemas and tables for that database, and press Esc to return to the summary view.
In the Statements view, press Enter to save the selected SQL text and i to inspect statement timings and the full query in a detail modal.
In the Activity view, use a, w, b, and t to switch between active, waiting, blocking, and idle-in-transaction session subviews.
Use 1-8 to switch tabs, including the Replication view.