This python program does a general health check on a specific PostgreSQL cluster.
(c) 2016-2022 SQLEXEC LLC
GNU V3 and MIT licenses are conveyed accordingly.
Bugs can be reported @ [email protected]
It checks for a bunch of database health metrics including load, bloat, long queries, blocked queries, old versions, etc.
- python 2.6 or higher
- python packages: python-psutil, psycopg2
- psql client
- psutil for windows only: https://pypi.python.org/pypi?:action=display&name=psutil#downloads
- postgresql contrib package is necessary for vacuumlo functionality
You can see a sample report here: @ http://htmlpreview.github.io/?https://github.com/MichaelDBA/pg_report/blob/gh-pages/pg_report_example.html
All fields are optional except database and action. The verbose flag is only intended as a debugging feature.
-h <hostname or IP address>
-d <database>
-n <schema>
-p <PORT>
-U <db user>
-m [html format flag]
-r [dry run flag]
-v [verbose output flag, mostly used for debugging]
Run report on entire test database and output to html format for web browser viewing:
./pg_report.py -d test --html
- db user defaults to postgres if not provided as parameter.
- db port defaults to 5432 if not provided as parameter.
- Password must be in local .pgpass file or client authentication changed to trust or peer
- psql must be in the user's path
- No .psqlrc file is used.
- PG Major/Minor check
- Cache Hit Ratio
- Shared Preload Libraries
- Connections
- Idle in Transactions
- Long Running Queries
- Lock Waits
- Archiving Status
- Database conflicts, deadlocks, and temp_files.
- Checkpoint Frequency
- Configuration settings.
- Checkpoint, Background, and Backend Writers
- Identify orphaned large objects.
- Bloated tables/indexes are identified where at least 20% of the table/index is bloated or the wasted bytes is > 10 GB.
- Unused indexes
- Vacuum Freeze Candidates
- Analyze/Vacuum Analyze candidates
- PG memory configuration settings
- Linux Kernel Memory Capacity