https://github.com/awslabs/pg-collector

PG Collector for Postgresql is a sql script that gathers valuable database information and presents it in a consolidated HTML file which provides a convenient way to view and navigate between different sections of the report

https://github.com/awslabs/pg-collector

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.2%) to scientific vocabulary

Keywords

pg-collector postgres postgresql sql-script vacuum
Last synced: 5 months ago · JSON representation

Repository

PG Collector for Postgresql is a sql script that gathers valuable database information and presents it in a consolidated HTML file which provides a convenient way to view and navigate between different sections of the report

Basic Info
  • Host: GitHub
  • Owner: awslabs
  • License: mit-0
  • Language: HTML
  • Default Branch: main
  • Homepage:
  • Size: 703 KB
Statistics
  • Stars: 101
  • Watchers: 5
  • Forks: 24
  • Open Issues: 5
  • Releases: 19
Topics
pg-collector postgres postgresql sql-script vacuum
Created about 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.md

PG Collector

Overview

PG Collector for Postgresql is a sql script that gathers valuable database information and presents it in a consolidated HTML file which provides a convenient way to view and navigate between different sections of the report.

PG Collector is safe to run on production environments and does not create any database objects to produce the output.

With PG Collector an operator gains insights on various aspects of the database, such as: * Database size * Configuration parameters * Installed extensions * Vacuum & Statistics * Unused Indexes & invalid indexes * Users & Roles Info * Toast Tables Mapping * Database schemas * Fragmentation (Bloat) * Tablespaces Info * Memory setting * Tables and Indexes Size and info * Transaction ID * Replication slots * public Schema info * Unlogged Tables

and more, please check the example reports

Versioning Policy :

Starting from PostgreSQL 13, PG Collector will have a dedicated script for each PostgreSQL major version .

each PG Collector major version will have it is own branch and the main branch will be for PG Collector that support PostgreSQL 12 and older versions

How to download PG Collector that match your PostgreSQL major version ?

From pg-collector releases

select PG Collector version that match your PostgreSQL major version

How to check PG Collector version ?

  • from the PG Collector report header

  • from the PG Collector script header

PG Collector report header

Example of PG Collector report

pg_collector v2.9

pg_collector v2.7

All Sample reports in sample report folder.

PG Collector output

Report name:

PG Collector script will generate HTML file using the following naming convention pgcolletcor[DB Name]-[timestamp].html .

[DB Name] : is the database name that you are connected to.

Example : pg_collector_testdb-2020-10-10_030920.html

Report location:

PG Collector script will generate HTML file under /tmp directory.

How to run PG Collector script ( pg_collector.sql )

1- you need psql to be able to connect to the postgresql DB and run the pg_collector.sql script

2- Download pg_collector.sql in your laptop or the host that want to access the database from

3- login to the database using psql psql -h [hostname or RDS endpoint] -p [Port] -d [Database name ] -U [user name] 4- run the pg_collector.sql script

\i pg_collector.sql \q or use -f option in psql

psql -h [hostname or RDS endpoint] -p [Port] -d [Database name ] -U [user name] -f pg_collector.sql

Example :

``` mohamed@mydevhost ~ % psql -h testdb-instance-1.cimdlffuw.us-west-2.rds.amazonaws.com -p 5432 -d testdb -U mohamed psql (9.4.8, server 10.6) WARNING: psql major version 9.4, server major version 10.6. Some psql features might not work. SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help.

testdb=> \i pgcollector.sql Output format is html. Default footer is off. testdb=> \q mohamed@mydevhost ~ %ls -lhrt /tmp/pgcolletcor* -rw-r--r-- 1 mohamed mohamed 569K Oct 7 21:51 /tmp/pgcolletcortestdb-2019-10-07215146.html

``` 5- open the report using any internet browser

Notes:

1- It is ok to see below errors while executing the pgcolletcor.sql script if you did not install pgstat_statements extension

postgres=> \i pg_collector.sql Output format is html. Default footer is off. psql:pg_collector.sql:481: ERROR: relation "pg_stat_statements" does not exist LINE 10: from pg_stat_statements ^ psql:pg_collector.sql:495: ERROR: relation "pg_stat_statements" does not exist LINE 10: from pg_stat_statements ^ psql:pg_collector.sql:509: ERROR: relation "pg_stat_statements" does not exist LINE 10: from pg_stat_statements ^ psql:pg_collector.sql:523: ERROR: relation "pg_stat_statements" does not exist LINE 10: from pg_stat_statements ^ postgres=> \q

2- If the Database have Tens of thousands of tables , some queries can take longer time . use statement_timeout to Abort any statement that takes more than the specified number of milliseconds. please check below example .

``` postgres=> set statementtimeout=30000; SET postgres=> \i pgcollector.sql Output format is html. Report name and location: /tmp/pgcollectorpostgres-2021-07-22194944.html psql:pgcollector.sql:1442: ERROR: canceling statement due to statement timeout postgres=>

```

3- It is acceptable to observe the following errors while executing the pg_collector.sql script on Amazon Aurora PostgreSQL if the Cluster Cache Manager is disabled.

``` postgres=> \i pgcollector.sql Output format is html. psql:/tmp/pgcollector.sql:2766: ERROR: Cluster Cache Manager is disabled psql:/tmp/pgcollector.sql:2769: ERROR: Cluster Cache Manager is disabled Report Generated Successfully Report name and location: /tmp/pgcollectorpostgres-2024-09-09161216.html

```

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Owner

  • Name: Amazon Web Services - Labs
  • Login: awslabs
  • Kind: organization
  • Location: Seattle, WA

AWS Labs

GitHub Events

Total
  • Create event: 3
  • Issues event: 1
  • Release event: 2
  • Watch event: 30
  • Push event: 1
  • Pull request review event: 1
  • Fork event: 3
Last Year
  • Create event: 3
  • Issues event: 1
  • Release event: 2
  • Watch event: 30
  • Push event: 1
  • Pull request review event: 1
  • Fork event: 3

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 6
  • Total pull requests: 1
  • Average time to close issues: 5 months
  • Average time to close pull requests: N/A
  • Total issue authors: 5
  • Total pull request authors: 1
  • Average comments per issue: 1.83
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • thottr (2)
  • jlonapp (1)
  • kbharathdba28 (1)
  • bala-gif (1)
  • veragini (1)
  • bramakrishnan-zuora (1)
  • spectershoe (1)
Pull Request Authors
  • kenchou73 (1)
Top Labels
Issue Labels
enhancement (3)
Pull Request Labels