banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Services

banshee/services-collection/services/postgresql/ssh/

databases

The size of each database of a PostgreSQL cluster and how fast it grows, by SSH and psql.

  • services
  • postgresql
  • postgres
  • database
  • size
  • growth
  • psql
  • ssh

by banshee1 installation1 version

v1Latest

Published on October 27, 2026. First version.

PostgreSQL databases, by SSH

Returns the size of each database of a PostgreSQL cluster, read by psql on the database server over SSH, and watches how fast it grows. Three watches are offered, each one set on the probe. No password leaves banshee.

Versions

PostgreSQL 10 and later (pg_monitor). Generic: no folder of version.

How it works

The collector runs, on the server, LC_ALL=C psql -X -A -t -q -v ON_ERROR_STOP=1 -p <port> -d <database> -c '<query>', each argument quoted apart, over the local socket:

SELECT COALESCE(json_object_agg(datname, pg_database_size(datname)), '{}'::json)
FROM pg_database WHERE datallowconn AND NOT datistemplate
{ "postgres" : 7623471, "app" : 1073741824 }
  • A database is named by its name; the templates, and the databases nobody may connect to, are left out.
  • size is the size on disk of the database, in MiB, its indexes and TOAST included.
  • "Database growing fast" raises when a database grows by more than the threshold within the window: by default 10 GiB in a day. A database that shrinks (a VACUUM FULL, a purge) starts the window again.
  • A cluster whose socket is absent, or that refuses the connection (psql exits 2), is critical: "PostgreSQL is not running". Any other failure of psql stops the collector misconfigured, with what psql said.
  • Nothing is written: pg_database_size only adds up the size of the files.

Prerequisites

The same as postgresql/ssh/connections: an SSH account without write rights, psql in its path, a PostgreSQL role of its name member of pg_monitor, allowed in by peer authentication over the local socket (or by its own ~/.pgpass), no sudo, and the fingerprint of the server's host key. pg_database_size needs CONNECT on each database, or pg_monitor; without either, the query fails and the collector stops misconfigured.

Variables

NameLabelSaysDefault
postgresql:portPortthe port of the cluster, which names its local socket5432
postgresql:databaseDatabasethe database psql connects topostgres

Outputs

NameLabelUnitPer instance
sizeSizeMiByes, per database

Watches

NameTitleKindDefaultsChecked by default
growthDatabase growing fastincrease, on sizewarning beyond 10240 MiB in 1 dyes
largeDatabase too largeabove a threshold, on sizeno threshold: set one on the probeno
missingDatabase missingexpected instances, on sizeno name given: it raises nothing until names are set on the probeno

Limits

  • The space left on the disk is not read here: the collectors of the file systems watch it (linux/ssh/filesystems).
  • pg_database_size walks the files of each database: on a cluster of many thousands of tables, the query takes a moment.
  • Not checked against a PostgreSQL: the function and the catalog are those of the PostgreSQL documentation ("Database Object Management Functions", pg_database).