database_size

(symlink: check_postgres_database_size) Checks the size of all databases and complains when they are too big.
There is no need to run this command more than once per database cluster.
Databases can be filtered with
the –include and –exclude options. See the BASIC FILTERING section
for more details.
They can also be filtered by the owner of the database with the
–includeuser and –excludeuser options.
See the USER NAME FILTERING section for more details.

The warning and critical options can be specified as bytes, kilobytes, megabytes,
gigabytes, terabytes, or exabytes. Each may be abbreviated to the first letter as well.
If no unit is given, the units are assumed to be bytes. There are not defaults for this
action: the warning and critical must be specified. The warning value cannot be greater
than the critical value. The output returns all databases sorted by size largest first,
showing both raw bytes and a "pretty" version of the size.

Example 1: Warn if any database on host flagg is over 1 TB in size, and critical if over 1.1 TB.

bash

  1. check_postgres_database_size --host=flagg --warning='1 TB' --critical='1.1 t'

Example 2: Give a critical if the database template1 on port 5432 is over 10 MB.

bash

  1. check_postgres_database_size --port=5432 --include=template1 --warning='10MB' --critical='10MB'

Example 3: Give a warning if any database on host ‘tardis’ owned by the user ‘tom’ is over 5 GB

bash

  1. check_postgres_database_size --host=tardis --includeuser=tom --warning='5 GB' --critical='10 GB'

For MRTG output, returns the size in bytes of the largest database on the first line,
and the name of the database on the fourth line.

disk_space

(symlink: check_postgres_disk_space) Checks on the available physical disk space used by Postgres. This action requires
that you have the executable "/bin/df" available to report on disk sizes, and it
also needs to be run as a superuser, so it can examine the data_directory
setting inside of Postgres. The –warning and –critical options are
given in either sizes or percentages. If using sizes, the standard unit types
are allowed: bytes, kilobytes, gigabytes, megabytes, gigabytes, terabytes, or
exabytes. Each may be abbreviated to the first letter only; no units at all
indicates ‘bytes’. The default values are ‘90%’ and ‘95%’.

This command checks the following things to determine all of the different
physical disks being used by Postgres.

data_directory – The disk that the main data directory is on.

log directory – The disk that the log files are on.

WAL file directory – The disk that the write-ahead logs are on (e.g. symlinked pg_xlog)

tablespaces – Each tablespace that is on a separate disk.

The output shows the total size used and available on each disk, as well as
the percentage, ordered by highest to lowest percentage used. Each item above
maps to a file system: these can be included or excluded. See the
BASIC FILTERING section for more details.

Example 1: Make sure that no file system is over 90% for the database on port 5432.

bash

  1. check_postgres_disk_space --port=5432 --warning='90%' --critical="90%'

Example 2: Check that all file systems starting with /dev/sda are smaller than 10 GB and 11 GB (warning and critical)

bash

  1. check_postgres_disk_space --port=5432 --warning='10 GB' --critical='11 GB' --include="~^/dev/sda"

For MRTG output, returns the size in bytes of the file system on the first line,
and the name of the file system on the fourth line.

fsm_pages

(symlink: check_postgres_fsm_pages) Checks how close a cluster is to the Postgres max_fsm_pages setting.
This action will only work for databases of 8.2 or higher, and it requires the contrib
module pg_freespacemap be installed. The –warning and –critical options should be expressed
as percentages. The number of used pages in the free-space-map is determined by looking in the
pg_freespacemap_relations view, and running a formula based on the formula used for
outputting free-space-map pageslots in the vacuum verbose command. The default values are 85% for the
warning and 95% for the critical.

Example 1: Give a warning when our cluster has used up 76% of the free-space pageslots, with pg_freespacemap installed in database robert

bash

  1. check_postgres_fsm_pages --dbname=robert --warning="76%"

While you need to pass in the name of the database where pg_freespacemap is installed (and optionally a schema name if you have
installed the module in a non-standard schema), you only need to run this check once per cluster. Also, checking this information
does require obtaining special locks on the free-space-map, so it is recommend you do not run this check with short intervals.

For MRTG output, returns the percent of free-space-map on the first line, and the number of pages currently used on
the second line.

fsm_relations

(symlink: check_postgres_fsm_relations) Checks how close a cluster is to the Postgres max_fsm_relations setting.
This action will only work for databases of 8.2 or higher, and it requires the contrib module pg_freespacemap be
installed. The –warning and –critical options should be expressed as percentages. The number of used relations
in the free-space-map is determined by looking in the pg_freespacemap_relations view. The default values are 85% for
the warning and 95% for the critical.

Example 1: Give a warning when our cluster has used up 80% of the free-space relations, with pg_freespacemap installed in database dylan, in non-standard schema emma

bash

  1. check_postgres_fsm_relations --dbname=dylan --warning="75%" --schema=emma

While you need to pass in the name of the database where pg_freespacemap is installed (and optionally a schema name
if you have installed the module in a non-standard schema), you only need to run this check once per cluster. Also,
checking this information does require obtaining special locks on the free-space-map, so it is recommend you do not
run this check with short intervals.

For MRTG output, returns the percent of free-space-map on the first line, the number of relations currently used on
the second line.

index_size

table_size

relation_size

(symlinks: check_postgres_index_size, check_postgres_table_size, and check_postgres_relation_size)
The actions table_size and index_size are simply variations of the
relation_size action, which checks for a relation that has grown too big.
Relations (in other words, tables and indexes) can be filtered with the
–include and –exclude options. See the BASIC FILTERING section
for more details. Relations can also be filtered by the user that owns them,
by using the –includeuser and –excludeuser options.
See the USER NAME FILTERING section for more details.

The values for the –warning and –critical options are file sizes, and
may have units of bytes, kilobytes, megabytes, gigabytes, terabytes, or exabytes.
Each can be abbreviated to the first letter. If no units are given, bytes are
assumed. There are no default values: both the warning and the critical option
must be given. The return text shows the size of the largest relation found.

If the –showperf option is enabled, all of the relations with their sizes
will be given. To prevent this, it is recommended that you set the
–perflimit option, which will cause the query to do a
ORDER BY size DESC LIMIT (perflimit).

Example 1: Give a critical if any table is larger than 600MB on host burrick.

bash

  1. check_postgres_table_size --critical='600 MB' --warning='600 MB' --host=burrick

Example 2: Warn if the table products is over 4 GB in size, and give a critical at 4.5 GB.

bash

  1. check_postgres_table_size --host=burrick --warning='4 GB' --critical='4.5 GB' --include=products

Example 3: Warn if any index not owned by postgres goes over 500 MB.

bash

  1. check_postgres_index_size --port=5432 --excludeuser=postgres -w 500MB -c 600MB

For MRTG output, returns the size in bytes of the largest relation, and the name of the database
and relation as the fourth line.

last_vacuum

last_autovacuum

last_analyze

Leave a Reply

Your email address will not be published. Required fields are marked *

clear formPost comment