zalando / pg_view

Get a detailed, real-time view of your PostgreSQL database and system metrics
https://pypi.python.org/pypi/pg-view
Other
494 stars 49 forks source link
monitoring

pg_view: Postgres Real-Time Activity View Utility

.. image:: https://travis-ci.org/zalando/pg_view.svg?branch=master :target: https://travis-ci.org/zalando/pg_view :alt: Build Status .. image:: https://img.shields.io/pypi/dw/pg-view.svg :target: https://pypi.python.org/pypi/pg-view :alt: PyPI Downloads .. image:: https://img.shields.io/pypi/l/pg-view.svg :target: https://pypi.python.org/pypi/pg-view :alt: License

Intro

pg_view is a powerful command-line tool that offers a detailed, real-time view of your PostgreSQL database and system metrics. It combines the indicators commonly displayed by sar or iostat with output from PostgreSQL's process activity view, and presents global and per-process statistics in an easy-to-interpret way.

pg_view shows these types of data:

pgview can be especially helpful when you're monitoring system load, query locks and I/O utilization during lengthy data migrations. It's also useful when you're running servers 24x7 and aiming for zero downtime. Learn more about it at tech.zalando.com <https://tech.zalando.com/blog/getting-a-quick-view-of-your-postgresql-stats/>.

Table of Contents

.. contents:: :local: :depth: 1 :backlinks: none

============================== Installation and Configuration

To run pg_view, you'll need:

By default, pg_view assumes that it can connect to a local PostgreSQL instance with the user postgres and no password. Some systems might require you to change your pg_hba.conf file or set the password in .pgpass. You can override the default user name with the -U command-line option or by setting the user key in the configuration file (see below).

================= How pg_view works

pg_view queries system/process information files once per second. It also queries the filesystem to obtain postgres data directory and xlog usage statistics. Please note that the latter function might add an extra load to your disk subsystem.

.. image:: https://raw.github.com/zalando/pg_view/master/images/pg_view_screenshot_new.png :alt: pg_view screenshot

==================== Connection Arguments

By default, pg_view tries to autodetect all PostgreSQL clusters running on the same host by performing the following steps (in order):

If the program can't detect your connection arguments using the algorithm above, you can specify those arguments manually using the configuration file supplied with the -c option. This file should consist of one or more sections, each containing a key = value pair. You can also use your Connection Service File.

The title of each section represents a database cluster name (this name is for display purposes only). The dbname parameter is postgres by default, and specifies the actual name of the database to connect to. The key-value pairs should contain connection parameters.

The valid keys are:

The special 'DEFAULT' section contains the parameters that apply for every database cluster if the corresponding parameter is missing from the database-specific section. For instance::

[DEFAULT]
port=5435

[testdb]
host=localhost

[testdb2]
host=/tmp/test

[testdb3]
host=192.168.1.0
port=5433
dbname=test

Upon reading this file, the application will try using port 5435 (database postgres) to connect to both testdb and testdb2 clusters, and using the database name test port 5433 to connect to testdb3.

If the auto-detection code works for you, you can select a single database by specifying the database instance name (in most cases, it will match the last component of $PGDATA) with the -i command-line option. If there is more than a single instance with the same name, you can additionally specify the required PG version with -V.

===== Usage

You can get a short description of available configuration options with pg_view --help

pg_view supports three output methods:

Descriptions of some of the options:

======= Hotkeys

========= Releasing

$ ./release.sh <NEW-VERSION>

============ Contributing

pg_view welcomes contributions; simply make a pull request.

======= License

Apache 2.0 <http://www.apache.org/licenses/LICENSE-2.0>_