.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` . ds C' 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CHECK_PGACTIVITY 1" .TH CHECK_PGACTIVITY 1 "2019-02-05" "Debian" "check_pgactivity" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" check_pgactivity \- PostgreSQL plugin for Nagios .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& check_pgactivity {\-w|\-\-warning THRESHOLD} {\-c|\-\-critical THRESHOLD} [\-s|\-\-service SERVICE ] [\-h|\-\-host HOST] [\-U|\-\-username ROLE] [\-p|\-\-port PORT] [\-d|\-\-dbname DATABASE] [\-S|\-\-dbservice SERVICE_NAME] [\-P|\-\-psql PATH] [\-\-debug] [\-\-status\-file FILE] [\-\-path PATH] [\-t|\-\-timemout TIMEOUT] \& check_pgactivity [\-l|\-\-list] \& check_pgactivity [\-\-help] .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" check_pgactivity is designed to monitor PostgreSQL clusters from Nagios. It offers many options to measure and monitor useful performance metrics. .IP "\fB\-s\fR, \fB\-\-service\fR \s-1SERVICE\s0" 4 .IX Item "-s, --service SERVICE" The Nagios service to run. See section \s-1SERVICES\s0 for a description of available services or use \f(CW\*(C`\-\-list\*(C'\fR for a short service and description list. .IP "\fB\-h\fR, \fB\-\-host\fR \s-1HOST\s0" 4 .IX Item "-h, --host HOST" Database server host or socket directory (default: \f(CW$PGHOST\fR or \*(L"localhost\*(R") .Sp See section \f(CW\*(C`CONNECTIONS\*(C'\fR for more informations. .IP "\fB\-U\fR, \fB\-\-username\fR \s-1ROLE\s0" 4 .IX Item "-U, --username ROLE" Database user name (default: \f(CW$PGUSER\fR or \*(L"postgres\*(R"). .Sp See section \f(CW\*(C`CONNECTIONS\*(C'\fR for more informations. .IP "\fB\-p\fR, \fB\-\-port\fR \s-1PORT\s0" 4 .IX Item "-p, --port PORT" Database server port (default: \f(CW$PGPORT\fR or \*(L"5432\*(R"). .Sp See section \f(CW\*(C`CONNECTIONS\*(C'\fR for more informations. .IP "\fB\-d\fR, \fB\-\-dbname\fR \s-1DATABASE\s0" 4 .IX Item "-d, --dbname DATABASE" Database name to connect to (default: \f(CW$PGDATABASE\fR or \*(L"template1\*(R"). .Sp \&\fB\s-1WARNING\s0\fR! This is not necessarily one of the database that will be checked. See \f(CW\*(C`\-\-dbinclude\*(C'\fR and \f(CW\*(C`\-\-dbexclude\*(C'\fR . .Sp See section \f(CW\*(C`CONNECTIONS\*(C'\fR for more informations. .IP "\fB\-S\fR, \fB\-\-dbservice\fR \s-1SERVICE_NAME\s0" 4 .IX Item "-S, --dbservice SERVICE_NAME" The connection service name from pg_service.conf to use. .Sp See section \f(CW\*(C`CONNECTIONS\*(C'\fR for more informations. .IP "\fB\-\-dbexclude\fR \s-1REGEXP\s0" 4 .IX Item "--dbexclude REGEXP" Some services automatically check all the databases of your cluster (note: that does not mean they always need to connect on all of them to check them though). \f(CW\*(C`\-\-dbexclude\*(C'\fR excludes any database whose name matches the given Perl regular expression. Repeat this option as many time as needed. .Sp See \f(CW\*(C`\-\-dbinclude\*(C'\fR as well. If a database match both dbexclude and dbinclude arguments, it is excluded. .IP "\fB\-\-dbinclude\fR \s-1REGEXP\s0" 4 .IX Item "--dbinclude REGEXP" Some services automatically check all the databases of your cluster (note: that does not imply that they always need to connect to all of them though). Some always exclude the 'postgres' database and templates. \f(CW\*(C`\-\-dbinclude\*(C'\fR checks \fB\s-1ONLY\s0\fR databases whose names match the given Perl regular expression. Repeat this option as many time as needed. .Sp See \f(CW\*(C`\-\-dbexclude\*(C'\fR as well. If a database match both dbexclude and dbinclude arguments, it is excluded. .IP "\fB\-w\fR, \fB\-\-warning\fR \s-1THRESHOLD\s0" 4 .IX Item "-w, --warning THRESHOLD" The Warning threshold. .IP "\fB\-c\fR, \fB\-\-critical\fR \s-1THRESHOLD\s0" 4 .IX Item "-c, --critical THRESHOLD" The Critical threshold. .IP "\fB\-F\fR, \fB\-\-format\fR \s-1OUTPUT_FORMAT\s0" 4 .IX Item "-F, --format OUTPUT_FORMAT" The output format. Supported output are: \f(CW\*(C`binary\*(C'\fR, \f(CW\*(C`debug\*(C'\fR, \f(CW\*(C`human\*(C'\fR, \&\f(CW\*(C`nagios\*(C'\fR and \f(CW\*(C`nagios_strict\*(C'\fR. .Sp Using the \f(CW\*(C`binary\*(C'\fR format, the results are written in a binary file (using perl module \f(CW\*(C`Storable\*(C'\fR) given in argument \f(CW\*(C`\-\-output\*(C'\fR. If no output is given, defaults to file \f(CW\*(C`check_pgactivity.out\*(C'\fR in the same directory as the script. .Sp The \f(CW\*(C`nagios_strict\*(C'\fR format is equivalent to the \f(CW\*(C`nagios\*(C'\fR format. The only difference is that it enforces the unit follow the strict Nagios specs: B, c, s or %. Any unit absent from this list is dropped (Bps, Tps, etc). .IP "\fB\-\-tmpdir\fR \s-1DIRECTORY\s0" 4 .IX Item "--tmpdir DIRECTORY" Path to a directory where the script can create temporary files. The script relies on the system default temporary directory if possible. .IP "\fB\-P\fR, \fB\-\-psql\fR \s-1FILE\s0" 4 .IX Item "-P, --psql FILE" Path to the \f(CW\*(C`psql\*(C'\fR executable (default: \*(L"psql\*(R"). .IP "\fB\-\-status\-file\fR \s-1PATH\s0" 4 .IX Item "--status-file PATH" Path to the file where service status information is kept between successive calls. Default is to save check_pgactivity.data in the same directory as the script. .IP "\fB\-\-dump\-status\-file\fR" 4 .IX Item "--dump-status-file" Dump the content of the status file and exit. This is useful for debugging purpose. .IP "\fB\-\-dump\-bin\-file\fR [\s-1PATH\s0]" 4 .IX Item "--dump-bin-file [PATH]" Dump the content of the given binary file previously created using \&\f(CW\*(C`\-\-format binary\*(C'\fR. If no path is given, defaults to file \&\f(CW\*(C`check_pgactivity.out\*(C'\fR in the same directory as the script. .IP "\fB\-t\fR, \fB\-\-timeout\fR \s-1TIMEOUT\s0" 4 .IX Item "-t, --timeout TIMEOUT" Timeout (default: \*(L"30s\*(R"), as raw (in seconds) or as an interval. This timeout will be used as \f(CW\*(C`statement_timeout\*(C'\fR for psql and \s-1URL\s0 timeout for \f(CW\*(C`minor_version\*(C'\fR service. .IP "\fB\-l\fR, \fB\-\-list\fR" 4 .IX Item "-l, --list" List available services. .IP "\fB\-V\fR, \fB\-\-version\fR" 4 .IX Item "-V, --version" Print version and exit. .IP "\fB\-\-debug\fR" 4 .IX Item "--debug" Print some debug messages. .IP "\fB\-?\fR, \fB\-\-help\fR" 4 .IX Item "-?, --help" Show this help page. .SS "\s-1THRESHOLDS\s0" .IX Subsection "THRESHOLDS" \&\s-1THRESHOLDS\s0 provided as warning and critical values can be raw numbers, percentages, intervals or sizes. Each available service supports one or more formats (eg. a size and a percentage). .IP "\fBPercentage\fR" 4 .IX Item "Percentage" If \s-1THRESHOLD\s0 is a percentage, the value should end with a '%' (no space). For instance: 95%. .IP "\fBInterval\fR" 4 .IX Item "Interval" If \s-1THRESHOLD\s0 is an interval, the following units are accepted (not case sensitive): s (second), m (minute), h (hour), d (day). You can use more than one unit per given value. If not set, the last unit is in seconds. For instance: \*(L"1h 55m 6\*(R" = \*(L"1h55m6s\*(R". .IP "\fBSize\fR" 4 .IX Item "Size" If \s-1THRESHOLD\s0 is a size, the following units are accepted (not case sensitive): b (Byte), k (\s-1KB\s0), m (\s-1MB\s0), g (\s-1GB\s0), t (\s-1TB\s0), p (\s-1PB\s0), e (\s-1EB\s0) or Z (\s-1ZB\s0). Only integers are accepted. Eg. \f(CW\*(C`1.5MB\*(C'\fR will be refused, use \f(CW\*(C`1500kB\*(C'\fR. .Sp The factor between units is 1024 bytes. Eg. \f(CW\*(C`1g = 1G = 1024*1024*1024.\*(C'\fR .SS "\s-1CONNECTIONS\s0" .IX Subsection "CONNECTIONS" check_pgactivity allows two different connection specifications: by service or by specifying values for host, user, port, and database. Some services can run on multiple hosts, or needs to connect to multiple hosts. .PP You might specify one of the parameters below to connect to your PostgreSQL instance. If you don't, no connection parameters are given to psql: connection relies on binary defaults and environment. .PP The format for connection parameters is: .ie n .IP "\fBParameter\fR \*(C`\-\-dbservice SERVICE_NAME\*(C'" 4 .el .IP "\fBParameter\fR \f(CW\*(C`\-\-dbservice SERVICE_NAME\*(C'\fR" 4 .IX Item "Parameter --dbservice SERVICE_NAME" Define a new host using the given service. Multiple hosts can be defined by listing multiple services separated by a comma. Eg. .Sp .Vb 1 \& \-\-dbservice service1,service2 .Ve .ie n .IP "\fBParameters\fR \*(C`\-\-host HOST\*(C', \*(C`\-\-port PORT\*(C', \*(C`\-\-user ROLE\*(C' or \*(C`\-\-dbname DATABASE\*(C'" 4 .el .IP "\fBParameters\fR \f(CW\*(C`\-\-host HOST\*(C'\fR, \f(CW\*(C`\-\-port PORT\*(C'\fR, \f(CW\*(C`\-\-user ROLE\*(C'\fR or \f(CW\*(C`\-\-dbname DATABASE\*(C'\fR" 4 .IX Item "Parameters --host HOST, --port PORT, --user ROLE or --dbname DATABASE" One parameter is enough to define a new host. Usual environment variables (\s-1PGHOST, PGPORT, PGDATABASE, PGUSER, PGSERVICE\s0) or default values are used for missing parameters. .Sp If multiple values are given, define as many host as maximum given values. .Sp Values are associated by position. Eg.: .Sp .Vb 1 \& \-\-host h1,h2 \-\-port 5432,5433 .Ve .Sp Means \*(L"host=h1 port=5432\*(R" and \*(L"host=h2 port=5433\*(R". .Sp If the number of values is different between parameters, any host missing a parameter will use the first given value for this parameter. Eg.: .Sp .Vb 1 \& \-\-host h1,h2 \-\-port 5433 .Ve .Sp Means: \*(L"host=h1 port=5433\*(R" and \*(L"host=h2 port=5433\*(R". .IP "\fBServices are defined first\fR" 4 .IX Item "Services are defined first" For instance: .Sp .Vb 1 \& \-\-dbservice s1 \-\-host h1 \-\-port 5433 .Ve .Sp means: use \*(L"service=s1\*(R" and \*(L"host=h1 port=5433\*(R" in this order. If the service supports only one host, the second host is ignored. .IP "\fBMutual exclusion between both methods\fR" 4 .IX Item "Mutual exclusion between both methods" You can not overwrite services connections variables with parameters \f(CW\*(C`\-\-host HOST\*(C'\fR, \f(CW\*(C`\-\-port PORT\*(C'\fR, \f(CW\*(C`\-\-user ROLE\*(C'\fR or \f(CW\*(C`\-\-dbname DATABASE\*(C'\fR .SS "\s-1SERVICES\s0" .IX Subsection "SERVICES" Descriptions and parameters of available services. .IP "\fBarchive_folder\fR" 4 .IX Item "archive_folder" Check if all archived WALs exist between the oldest and the latest \s-1WAL\s0 in the archive folder and make sure they are 16MB. The given folder must have archived files from \s-1ONE\s0 cluster. The version of PostgreSQL that created the archives is only checked on the last one, for performance consideration. .Sp This service requires the argument \f(CW\*(C`\-\-path\*(C'\fR on the command line to specify the archive folder path to check. Obviously, it must have access to this folder at the filesystem level: you may have to execute it on the archiving server rather than on the PostgreSQL instance. .Sp The optional argument \f(CW\*(C`\-\-suffix\*(C'\fR defines the suffix of your archived WALs; this is useful for compressed WALs (eg. .gz, .bz2, ...). Default is no suffix. .Sp This service needs to read the header of one of the archives to define how many segments a \s-1WAL\s0 owns. Check_pgactivity automatically handles files with extensions .gz, .bz2, .xz, .zip or .7z using the following commands: .Sp .Vb 5 \& gzip \-dc \& bzip2 \-dc \& xz \-dc \& unzip \-qqp \& 7z x \-so .Ve .Sp If needed, provide your own command that writes the uncompressed file to standard output with the \f(CW\*(C`\-\-unarchiver\*(C'\fR argument. .Sp Optional argument \f(CW\*(C`\-\-ignore\-wal\-size\*(C'\fR skips the \s-1WAL\s0 size check. This is useful if your archived WALs are compressed and check_pgactivity is unable to guess the original size. Here are the commands check_pgactivity uses to guess the original size of .gz, .xz or .zip files: .Sp .Vb 3 \& gzip \-ql \& xz \-ql \& unzip \-qql .Ve .Sp Default behaviour is to check the WALs size. .Sp Perfdata contains the number of archived WALs and the age of the most recent one. .Sp Critical and Warning define the max age of the latest archived \s-1WAL\s0 as an interval (eg. 5m or 300s ). .Sp Required privileges: unprivileged role; the system user needs read access to archived \s-1WAL\s0 files. .Sp Sample commands: .Sp .Vb 4 \& check_pgactivity \-s archive_folder \-\-path /path/to/archives \-w 15m \-c 30m \& check_pgactivity \-s archive_folder \-\-path /path/to/archives \-\-suffix .gz \-w 15m \-c 30m \& check_pgactivity \-s archive_folder \-\-path /path/to/archives \-\-ignore\-wal\-size \-\-suffix .bz2 \-w 15m \-c 30m \& check_pgactivity \-s archive_folder \-\-path /path/to/archives \-\-unarchiver "unrar p" \-\-ignore\-wal\-size \-\-suffix .rar \-w 15m \-c 30m .Ve .IP "\fBarchiver\fR (8.1+)" 4 .IX Item "archiver (8.1+)" Check if the archiver is working properly and the number of \s-1WAL\s0 files ready to archive. .Sp Perfdata returns the number of \s-1WAL\s0 files waiting to be archived. .Sp Critical and Warning thresholds are optional. They apply on the number of files waiting to be archived. They only accept a raw number of files. .Sp Whatever the given threshold, a critical alert is raised if the archiver process did not archive the oldest waiting \s-1WAL\s0 to be archived since last call. .Sp Required privileges: unprivileged role (10+); superuser (<10). .IP "\fBautovacuum\fR (8.1+)" 4 .IX Item "autovacuum (8.1+)" Check the autovacuum activity on the cluster. .Sp Perfdata contains the age of oldest running autovacuum and the number of workers by type (\s-1VACUUM, VACUUM ANALYZE, ANALYZE, VACUUM FREEZE\s0). .Sp Thresholds, if any, are ignored. .Sp Required privileges: unprivileged role. .IP "\fBbackends\fR (all)" 4 .IX Item "backends (all)" Check the total number of connections in the PostgreSQL cluster. .Sp Perfdata contains the number of connections per database. .Sp Critical and Warning thresholds accept either a raw number or a percentage (eg. 80%). When a threshold is a percentage, it is compared to the difference between the cluster parameters \f(CW\*(C`max_connections\*(C'\fR and \&\f(CW\*(C`superuser_reserved_connections\*(C'\fR. .Sp Required privileges: an unprivileged user only sees its own queries; a pg_monitor (10+) or superuser (<10) role is required to see all queries. .IP "\fBbackends_status\fR (8.2+)" 4 .IX Item "backends_status (8.2+)" Check the status of all backends. Depending on your PostgreSQL version, statuses are: \f(CW\*(C`idle\*(C'\fR, \f(CW\*(C`idle in transaction\*(C'\fR, \f(CW\*(C`idle in transaction (aborted)\*(C'\fR (>=9.0 only), \f(CW\*(C`fastpath function call\*(C'\fR, \f(CW\*(C`active\*(C'\fR, \f(CW\*(C`waiting for lock\*(C'\fR, \&\f(CW\*(C`undefined\*(C'\fR, \f(CW\*(C`disabled\*(C'\fR and \f(CW\*(C`insufficient privilege\*(C'\fR. \&\fBinsufficient privilege\fR appears when you are not allowed to see the statuses of other connections. .Sp This service supports the argument \f(CW\*(C`\-\-exclude REGEX\*(C'\fR to exclude queries matching the given regular expression. .Sp You can use multiple \f(CW\*(C`\-\-exclude REGEX\*(C'\fR arguments. .Sp Critical and Warning thresholds are optional. They accept a list of \&'status_label=value' separated by a comma. Available labels are \f(CW\*(C`idle\*(C'\fR, \&\f(CW\*(C`idle_xact\*(C'\fR, \f(CW\*(C`aborted_xact\*(C'\fR, \f(CW\*(C`fastpath\*(C'\fR, \f(CW\*(C`active\*(C'\fR and \f(CW\*(C`waiting\*(C'\fR. Values are raw numbers or time units and empty lists are forbidden. Here is an example: .Sp .Vb 1 \& \-w \*(Aqwaiting=5,idle_xact=10\*(Aq \-c \*(Aqwaiting=20,idle_xact=30,active=1d\*(Aq .Ve .Sp Perfdata contains the number of backends for each status and the oldest one for each of them, for 8.2+. .Sp Note that the number of backends reported in Nagios message \fBincludes\fR excluded backends. .Sp Required privileges: an unprivileged user only sees its own queries; a pg_monitor (10+) or superuser (<10) role is required to see all queries. .IP "\fBbackup_label_age\fR (8.1+)" 4 .IX Item "backup_label_age (8.1+)" Check the age of the backup label file. .Sp Perfdata returns the age of the backup_label file, \-1 if not present. .Sp Critical and Warning thresholds only accept an interval (eg. 1h30m25s). .Sp Required privileges: unprivileged role (9.3+); superuser (<9.3) .IP "\fBbgwriter\fR (8.3+)" 4 .IX Item "bgwriter (8.3+)" Check the percentage of pages written by backends since last check. .Sp This service uses the status file (see \f(CW\*(C`\-\-status\-file\*(C'\fR parameter). .Sp Perfdata contains the ratio per second for each \f(CW\*(C`pg_stat_bgwriter\*(C'\fR counter since last execution. Units Nps for checkpoints, max written clean and fsyncs are the number of \*(L"events\*(R" per second. .Sp Critical and Warning thresholds are optional. If set, they \fIonly\fR accept a percentage. .Sp Required privileges: unprivileged role. .IP "\fBbtree_bloat\fR" 4 .IX Item "btree_bloat" Estimate bloat on B\-tree indexes. .Sp Warning and critical thresholds accept a comma-separated list of either raw number(for a size), size (eg. 125M) or percentage. The thresholds apply to \&\fBbloat\fR size, not object size. If a percentage is given, the threshold will apply to the bloat size compared to the total index size. If multiple threshold values are passed, check_pgactivity will choose the largest (bloat size) value. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. The 'postgres' database and templates are always excluded. .Sp It also supports a \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameter to exclude relations matching a regular expression. The regular expression applies to \&\*(L"database.schema_name.relation_name\*(R". This enables you to filter either on a relation name for all schemas and databases, on a qualified named relation (schema + relation) for all databases or on a qualified named relation in only one database. .Sp You can use multiple \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameters. .Sp Perfdata will return the number of indexes of concern, by warning and critical threshold per database. .Sp A list of the bloated indexes will be returned after the perfdata. This list contains the fully qualified bloated index name, the estimated bloat size, the index size and the bloat percentage. .Sp Required privileges: superuser (<10) able to log in all databases, or at least those in \f(CW\*(C`\-\-dbinclude\*(C'\fR; superuser (<10); on PostgreSQL 10+, a user with the role pg_monitor suffices, provided that you grant \s-1SELECT\s0 on the system table pg_statistic to the pg_monitor role, in each database of the cluster: \&\f(CW\*(C`GRANT SELECT ON pg_statistic TO pg_monitor;\*(C'\fR .IP "\fBcommit_ratio\fR (all)" 4 .IX Item "commit_ratio (all)" Check the commit and rollback rate per second since last call. .Sp This service uses the status file (see \-\-status\-file parameter). .Sp Perfdata contains the commit rate, rollback rate, transaction rate and rollback ratio for each database since last call. .Sp Critical and Warning thresholds are optional. They accept a list of comma separated 'label=value'. Available labels are \fBrollbacks\fR, \fBrollback_rate\fR and \fBrollback_ratio\fR, which will be compared to the number of rollbacks, the rollback rate and the rollback ratio of each database. Warning or critical will be raised if the reported value is greater than \fBrollbacks\fR, \fBrollback_rate\fR or \&\fBrollback_ratio\fR. .Sp Required privileges: unprivileged role. .IP "\fBconfiguration\fR (8.0+)" 4 .IX Item "configuration (8.0+)" Check the most important settings. .Sp Warning and Critical thresholds are ignored. .Sp Specific parameters are : \&\f(CW\*(C`\-\-work_mem\*(C'\fR, \f(CW\*(C`\-\-maintenance_work_mem\*(C'\fR, \f(CW\*(C`\-\-shared_buffers\*(C'\fR,\f(CW\*(C`\-\-wal_buffers\*(C'\fR, \&\f(CW\*(C`\-\-checkpoint_segments\*(C'\fR, \f(CW\*(C`\-\-effective_cache_size\*(C'\fR, \f(CW\*(C`\-\-no_check_autovacuum\*(C'\fR, \&\f(CW\*(C`\-\-no_check_fsync\*(C'\fR, \f(CW\*(C`\-\-no_check_enable\*(C'\fR, \f(CW\*(C`\-\-no_check_track_counts\*(C'\fR. .Sp Required privileges: unprivileged role. .IP "\fBconnection\fR (all)" 4 .IX Item "connection (all)" Perform a simple connection test. .Sp No perfdata is returned. .Sp This service ignores critical and warning arguments. .Sp Required privileges: unprivileged role. .IP "\fBcustom_query\fR (all)" 4 .IX Item "custom_query (all)" Perform the given user query. .Sp Specify the query with \f(CW\*(C`\-\-query\*(C'\fR. The first column will be used to perform the test for the status if warning and critical are provided. .Sp The warning and critical arguments are optional. They can be of format integer (default), size or time depending on the \f(CW\*(C`\-\-type\*(C'\fR argument. Warning and Critical will be raised if they are greater than the first column, or less if the \f(CW\*(C`\-\-reverse\*(C'\fR option is used. .Sp All other columns will be used to generate the perfdata. Each field name is used as the name of the perfdata. The field value must contain your perfdata value and its unit appended to it. You can add as many fields as needed. Eg.: .Sp .Vb 2 \& SELECT pg_database_size(\*(Aqpostgres\*(Aq), \& pg_database_size(\*(Aqpostgres\*(Aq)||\*(AqB\*(Aq AS db_size .Ve .Sp Required privileges: unprivileged role (depends on the query). .IP "\fBdatabase_size\fR (8.1+)" 4 .IX Item "database_size (8.1+)" \&\fBCheck the variation\fR of database sizes, and \fBreturn the size\fR of every databases. .Sp This service uses the status file (see \f(CW\*(C`\-\-status\-file\*(C'\fR parameter). .Sp Perfdata contains the size of each database. .Sp Critical and Warning thresholds accept either a raw number, a percentage, or a size (eg. 2.5G). They are applied on the size difference for each database since the last execution. The aim is to detect unexpected database size variation. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. .Sp Required privileges: unprivileged role. .IP "\fBhit_ratio\fR (all)" 4 .IX Item "hit_ratio (all)" Check the cache hit ratio on the cluster. .Sp This service uses the status file (see \f(CW\*(C`\-\-status\-file\*(C'\fR parameter). .Sp Perfdata returns the cache hit ratio per database. Template databases and databases that do not allow connections will not be checked, nor will the databases which have never been accessed. .Sp Critical and Warning thresholds are optional. They only accept a percentage. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. .Sp Required privileges: unprivileged role. .IP "\fBhot_standby_delta\fR (9.0)" 4 .IX Item "hot_standby_delta (9.0)" Check the data delta between a cluster and its hot standbys. .Sp You must give the connection parameters for two or more clusters. .Sp Perfdata returns the data delta in bytes between the master and each hot standby cluster listed. .Sp Critical and Warning thresholds are optional. They can take one or two values separated by a comma. If only one value given, it applies to both received and replayed data. If two values are given, the first one applies to received data, the second one to replayed ones. These thresholds only accept a size (eg. 2.5G). .Sp This service raises a Critical if it doesn't find exactly \s-1ONE\s0 valid master cluster (ie. critical when 0 or 2 and more masters). .Sp Required privileges: unprivileged role. .IP "\fBis_hot_standby\fR (9.0+)" 4 .IX Item "is_hot_standby (9.0+)" Checks if the cluster is in recovery and accepts read only queries. .Sp This service ignores critical and warning arguments. .Sp No perfdata is returned. .Sp Required privileges: unprivileged role. .IP "\fBis_master\fR (all)" 4 .IX Item "is_master (all)" Checks if the cluster accepts read and/or write queries. This state is reported as \*(L"in production\*(R" by pg_controldata. .Sp This service ignores critical and warning arguments. .Sp No perfdata is returned. .Sp Required privileges: unprivileged role. .IP "\fBinvalid_indexes\fR" 4 .IX Item "invalid_indexes" Check if there is there are invalid indexes in a database. .Sp A critical alert is raised if an invalid index is detected. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. The 'postgres' database and templates are always excluded. .Sp This service supports a \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameter to exclude indexes matching a regular expression. The regular expression applies to \&\*(L"database.schema_name.index_name\*(R". This enables you to filter either on a relation name for all schemas and databases, on a qualified named index (schema + index) for all databases or on a qualified named index in only one database. .Sp You can use multiple \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameters. .Sp Perfdata will return the number of invalid indexes per database. .Sp A list of invalid indexes will be returned after the perfdata. This list contains the fully qualified index name. If excluded index is set, the number of exclude indexes is returned. .Sp Required privileges: unprivileged role able to log in all databases. .IP "\fBis_replay_paused\fR (9.1+)" 4 .IX Item "is_replay_paused (9.1+)" Checks if the replication is paused. The service will return \s-1UNKNOWN\s0 if executed on a master server. .Sp Thresholds are optional. They must be specified as interval. \s-1OK\s0 will always be returned if the standby is not paused, even if replication delta time hits the thresholds. .Sp Critical or warning are raised if last reported replayed timestamp is greater than given threshold \s-1AND\s0 some data received from the master are not applied yet. \&\s-1OK\s0 will always be returned if the standby is paused, or if the standby has already replayed everything from master and until some write activity happens on the master. .Sp Perfdata returned: * paused status (0 no, 1 yes, NaN if master) * lag time (in second) * data delta with master (0 no, 1 yes) .Sp Required privileges: unprivileged role. .IP "\fBlast_analyze\fR (8.2+)" 4 .IX Item "last_analyze (8.2+)" Check on each databases that the oldest \f(CW\*(C`analyze\*(C'\fR (from autovacuum or not) is not older than the given threshold. .Sp This service uses the status file (see \f(CW\*(C`\-\-status\-file\*(C'\fR parameter) with PostgreSQL 9.1+. .Sp Perfdata returns oldest \f(CW\*(C`analyze\*(C'\fR per database in seconds. With PostgreSQL 9.1+, the number of [auto]analyses per database since last call is also returned. .Sp Critical and Warning thresholds only accept an interval (eg. 1h30m25s) and apply to the oldest execution of analyse. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. The 'postgres' database and templates are always excluded. .Sp Required privileges: unprivileged role able to log in all databases. .IP "\fBlast_vacuum\fR (8.2+)" 4 .IX Item "last_vacuum (8.2+)" Check that the oldest vacuum (from autovacuum or otherwise) in each database in the cluster is not older than the given threshold. .Sp This service uses the status file (see \f(CW\*(C`\-\-status\-file\*(C'\fR parameter) with PostgreSQL 9.1+. .Sp Perfdata returns oldest vacuum per database in seconds. With PostgreSQL 9.1+, it also returns the number of [auto]vacuums per database since last execution. .Sp Critical and Warning thresholds only accept an interval (eg. 1h30m25s) and apply to the oldest vacuum. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. The 'postgres' database and templates are always excluded. .Sp Required privileges: unprivileged role able to log in all databases. .IP "\fBlocks\fR (all)" 4 .IX Item "locks (all)" Check the number of locks on the hosts. .Sp Perfdata returns the number of locks, by type. .Sp Critical and Warning thresholds accept either a raw number of locks or a percentage. For percentage, it is computed using the following limits for 7.4 to 8.1: .Sp .Vb 1 \& max_locks_per_transaction * max_connections .Ve .Sp for 8.2+: .Sp .Vb 1 \& max_locks_per_transaction * (max_connections + max_prepared_transactions) .Ve .Sp for 9.1+, regarding lockmode : .Sp .Vb 2 \& max_locks_per_transaction * (max_connections + max_prepared_transactions) \&or max_pred_locks_per_transaction * (max_connections + max_prepared_transactions) .Ve .Sp Required privileges: unprivileged role. .IP "\fBlongest_query\fR (all)" 4 .IX Item "longest_query (all)" Check the longest running query in the cluster. .Sp Perfdata contains the max/avg/min running time and the number of queries per database. .Sp Critical and Warning thresholds only accept an interval. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. .Sp It also supports argument \f(CW\*(C`\-\-exclude REGEX\*(C'\fR to exclude queries matching the given regular expression from the check. .Sp Above 9.0, it also supports \f(CW\*(C`\-\-exclude REGEX\*(C'\fR to filter out application_name. .Sp You can use multiple \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameters. .Sp Required privileges: an unprivileged role only checks its own queries; a pg_monitor (10+) or superuser (<10) role is required to check all queries. .IP "\fBmax_freeze_age\fR (all)" 4 .IX Item "max_freeze_age (all)" Checks oldest database by transaction age. .Sp Critical and Warning thresholds are optional. They accept either a raw number or percentage for PostgreSQL 8.2 and more. If percentage is given, the thresholds are computed based on the \*(L"autovacuum_freeze_max_age\*(R" parameter. 100% means that some table(s) reached the maximum age and will trigger an autovacuum freeze. Percentage thresholds should therefore be greater than 100%. .Sp Even with no threshold, this service will raise a critical alert if a database has a negative age. .Sp Perfdata returns the age of each database. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. .Sp Required privileges: unprivileged role. .IP "\fBminor_version\fR (all)" 4 .IX Item "minor_version (all)" Check if the cluster is running the most recent minor version of PostgreSQL. .Sp Latest versions of PostgreSQL can be fetched from PostgreSQL official website if check_pgactivity has access to it, or must be given as a parameter. .Sp Without \f(CW\*(C`\-\-critical\*(C'\fR or \f(CW\*(C`\-\-warning\*(C'\fR parameters, this service attempts to fetch the latest version numbers online. A critical alert is raised if the minor version is not the most recent. .Sp You can optionally set the path to your prefered retrieval tool using the \f(CW\*(C`\-\-path\*(C'\fR parameter (eg. \f(CW\*(C`\-\-path \*(Aq/usr/bin/wget\*(Aq\*(C'\fR). Supported programs are: \&\s-1GET,\s0 wget, curl, fetch, lynx, links, links2. .Sp If you do not want to (or cannot) query the PostgreSQL website, provide the expected versions using either \f(CW\*(C`\-\-warning\*(C'\fR \s-1OR\s0 \&\f(CW\*(C`\-\-critical\*(C'\fR, depending on which return value you want to raise. .Sp The given string must contain one or more \s-1MINOR\s0 versions separated by anything but a '.'. For instance, the following parameters are all equivalent: .Sp .Vb 4 \& \-\-critical "10.1 9.6.6 9.5.10 9.4.15 9.3.20 9.2.24 9.1.24 9.0.23 8.4.22" \& \-\-critical "10.1, 9.6.6, 9.5.10, 9.4.15, 9.3.20, 9.2.24, 9.1.24, 9.0.23, 8.4.22" \& \-\-critical "10.1,9.6.6,9.5.10,9.4.15,9.3.20,9.2.24,9.1.24,9.0.23,8.4.22" \& \-\-critical "10.1/9.6.6/9.5.10/9.4.15/9.3.20/9.2.24/9.1.24/9.0.23/8.4.22" .Ve .Sp Any other value than 3 numbers separated by dots (before version 10.x) or 2 numbers separated by dots (version 10 and above) will be ignored. If the running PostgreSQL major version is not found, the service raises an unknown status. .Sp Perfdata returns the numerical version of PostgreSQL. .Sp Required privileges: unprivileged role; access to http://www.postgresql.org required to download version numbers. .IP "\fBoldest_2pc\fR (8.1+)" 4 .IX Item "oldest_2pc (8.1+)" Check the oldest \fItwo-phase commit transaction\fR (aka. prepared transaction) in the cluster. .Sp Perfdata contains the max/avg age time and the number of prepared transactions per databases. .Sp Critical and Warning thresholds only accept an interval. .Sp Required privileges: unprivileged role. .IP "\fBoldest_idlexact\fR (8.3+)" 4 .IX Item "oldest_idlexact (8.3+)" Check the oldest \fIidle\fR transaction. .Sp Perfdata contains the max/avg age and the number of idle transactions per databases. .Sp Critical and Warning thresholds only accept an interval. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. .Sp Above 9.2, it supports \f(CW\*(C`\-\-exclude\*(C'\fR to filter out connections. Eg., to filter out pg_dump and pg_dumpall, set this to 'pg_dump,pg_dumpall'. .Sp Required privileges: an unprivileged role checks only its own queries; a pg_monitor (10+) or superuser (<10) role is required to check all queries. .IP "\fBpg_dump_backup\fR" 4 .IX Item "pg_dump_backup" Check the age and size of backups. .Sp This service uses the status file (see \f(CW\*(C`\-\-status\-file\*(C'\fR parameter). .Sp The \f(CW\*(C`\-\-path\*(C'\fR argument contains the location to the backup folder. The supported format is a glob pattern matching every folder or file that you need to check. If appropriate, the probe should be run as a user with sufficient privileges to check for the existence of files. .Sp The \f(CW\*(C`\-\-pattern\*(C'\fR is required, and must contain a regular expression matching the backup file name, extracting the database name from the first matching group. For example, the pattern \*(L"(\ew+)\-\ed+.dump\*(R" can be used to match dumps of the form: .Sp .Vb 5 \& mydb\-20150803.dump \& otherdb\-20150803.dump \& mydb\-20150806.dump \& otherdb\-20150806.dump \& mydb\-20150807.dump .Ve .Sp Optionally, a \f(CW\*(C`\-\-global\-pattern\*(C'\fR option can be supplied to check for an additional global file. .Sp Tip : For compatibility with pg_back, you should use \f(CW\*(C`\-\-path\*(C'\fR '/path/*{dump,sql}' \f(CW\*(C`\-\-pattern\*(C'\fR '(\ew+)_[0\-9\-_]+.dump' \f(CW\*(C`\-\-global\-pattern\*(C'\fR 'pg_global_[0\-9\-_]+.sql' .Sp The \f(CW\*(C`\-\-critical\*(C'\fR and \f(CW\*(C`\-\-warning\*(C'\fR thresholds are optional. They accept a list of 'metric=value' separated by a comma. Available metrics are \f(CW\*(C`oldest\*(C'\fR and \&\f(CW\*(C`newest\*(C'\fR, respectively the age of the oldest and newest backups, and \f(CW\*(C`size\*(C'\fR, which must be the maximum variation of size since the last check, expressed as a size or a percentage. \f(CW\*(C`mindeltasize\*(C'\fR, expressed in B, is the minimum variation of size needed to raise an alert. .Sp This service supports the \f(CW\*(C`\-\-dbinclude\*(C'\fR and \f(CW\*(C`\-\-dbexclude\*(C'\fR arguments, to respectively test for the presence of include or exclude files. .Sp The argument \f(CW\*(C`\-\-exclude\*(C'\fR enables you to exclude files younger than an interval. This is useful to ignore files from a backup in progress. Eg., if your backup process takes 2h, set this to '125m'. .Sp Perfdata returns the age of the oldest and newest backups, as well as the size of the newest backups. .Sp Required privileges: unprivileged role; the system user needs read access on the directory containing the dumps (but not on the dumps themselves). .IP "\fBpga_version\fR" 4 .IX Item "pga_version" Check if this script is running the given version of check_pgactivity. You must provide the expected version using either \f(CW\*(C`\-\-warning\*(C'\fR \s-1OR\s0 \&\f(CW\*(C`\-\-critical\*(C'\fR. .Sp No perfdata is returned. .Sp Required privileges: none. .IP "\fBpgdata_permission\fR (8.2+)" 4 .IX Item "pgdata_permission (8.2+)" Check that the instance data directory rights are 700, and belongs to the system user currently running postgresql. .Sp The check on rights works on all Unix systems. .Sp Checking the user only works on Linux systems (it uses /proc to avoid dependencies). Before 9.3, you need to provide the expected owner using the \&\f(CW\*(C`\-\-uid\*(C'\fR argument, or the owner will not be checked. .Sp Required privileges: <11:superuser v11: user with pg_monitor or pg_read_all_setting The system user must also be able to read the folder containing \&\s-1PGDATA:\s0 \fBthe service has to be executed locally on the monitored server.\fR .IP "\fBreplication_slots\fR (9.4+)" 4 .IX Item "replication_slots (9.4+)" Check the number of \s-1WAL\s0 files and pg_replslot files retained by each replication slots. .Sp Perfdata returns the number of \s-1WAL\s0 and pg_replslot files that each replication slot has to keep. This service needs superuser privileges since v10 to obtain pg_replslot files. Unless replslot_files will be at 0. .Sp Critical and Warning thresholds are optional. They accept either a raw number (for backward compatibility, only wal threshold will be used) or a list 'wal=value' and 'replslot=value'. Respectively number of kept wal files or number of files in pg_replslot for each slot. .Sp Required privileges: <10: unprivileged role v10: unprivileged role, or superuser to monitor logical replication v11: unpriviledged user with \s-1GRANT EXECUTE\s0 on function pg_ls_dir(text) .Sp Here is an example: .Sp .Vb 1 \& \-w \*(Aqwal=50,replslot=20\*(Aq \-c \*(Aqwal=100,replslot=40\*(Aq .Ve .IP "\fBsettings\fR (9.0+)" 4 .IX Item "settings (9.0+)" Check if the current settings have changed since they were stored in the service file. .Sp The \*(L"known\*(R" settings are recorded during the very first call of the service. To update the known settings after a configuration change, call this service again with the argument \f(CW\*(C`\-\-save\*(C'\fR. .Sp No perfdata. .Sp Critical and Warning thresholds are ignored. .Sp A Critical is raised if at least one parameter changed. .Sp Required privileges: unprivileged role. .IP "\fBsequences_exhausted\fR (7.4+)" 4 .IX Item "sequences_exhausted (7.4+)" Check all sequences assigned to a column (the smallserial, serial and bigserial types), and raise an alarm if the column or sequences gets too close to the maximum value. .Sp Perfdata returns the sequences that trigger the alert. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. The 'postgres' database and templates are always excluded. .Sp Critical and Warning thresholds accept a percentage of the sequence filled. .Sp Required privileges: unprivileged role able to log in all databases .IP "\fBstat_snapshot_age\fR (9.5+)" 4 .IX Item "stat_snapshot_age (9.5+)" Check the age of the statistics snapshot (statistics collector's statistics). This probe helps to detect a frozen stats collector process. .Sp Perfdata returns the statistics snapshot age. .Sp Critical and Warning thresholds accept a raw number of seconds. .Sp Required privileges: unprivileged role. .IP "\fBstreaming_delta\fR (9.1+)" 4 .IX Item "streaming_delta (9.1+)" Check the data delta between a cluster and its standbys in streaming replication. .Sp Optional argument \f(CW\*(C`\-\-slave\*(C'\fR allows you to specify some slaves that \s-1MUST\s0 be connected. This argument can be used as many times as desired to check multiple slave connections, or you can specify multiple slaves connections at one time, using comma separated values. Both methods can be used in a single call. The provided values must be of the form \*(L"\s-1APPLICATION_NAME IP\*(R".\s0 Both following examples will check for the presence of two slaves: .Sp .Vb 2 \& \-\-slave \*(Aqslave1 192.168.1.11\*(Aq \-\-slave \*(Aqslave2 192.168.1.12\*(Aq \& \-\-slave \*(Aqslave1 192.168.1.11\*(Aq,\*(Aqslave2 192.168.1.12\*(Aq .Ve .Sp This service supports a \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameter to exclude every result matching a regular expression on application_name or \s-1IP\s0 address fields. .Sp You can use multiple \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameters. .Sp Perfdata returns the data delta in bytes between the master and every standbies found, the number of standbies connected and the number of excluded standbies. .Sp Critical and Warning thresholds are optional. They can take one or two values separated by a comma. If only one value is supplied, it applies to both flushed and replayed data. If two values are supplied, the first one applies to flushed data, the second one to replayed data. These thresholds only accept a size (eg. 2.5G). .Sp Required privileges: unprivileged role. .IP "\fBtable_unlogged\fR (9.5+)" 4 .IX Item "table_unlogged (9.5+)" Check if tables are changed to unlogged. In 9.5, you can switch between logged and unlogged. .Sp Without \f(CW\*(C`\-\-critical\*(C'\fR or \f(CW\*(C`\-\-warning\*(C'\fR parameters, this service attempts to fetch all unlogged tables. .Sp A critical alert is raised if an unlogged table is detected. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. The 'postgres' database and templates are always excluded. .Sp This service supports a \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameter to exclude relations matching a regular expression. The regular expression applies to \&\*(L"database.schema_name.relation_name\*(R". This enables you to filter either on a relation name for all schemas and databases, on a qualified named relation (schema + relation) for all databases or on a qualified named relation in only one database. .Sp You can use multiple \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameters. .Sp Perfdata will return the number of unlogged tables per database. .Sp A list of the unlogged tables will be returned after the perfdata. This list contains the fully qualified table name. If \&\f(CW\*(C`\-\-exclude REGEX\*(C'\fR is set, the number of excluded tables is returned. .Sp Required privileges: unprivileged role able to log in all databases, or at least those in \f(CW\*(C`\-\-dbinclude\*(C'\fR. .IP "\fBtable_bloat\fR" 4 .IX Item "table_bloat" Estimate bloat on tables. .Sp Warning and critical thresholds accept a comma-separated list of either raw number(for a size), size (eg. 125M) or percentage. The thresholds apply to \&\fBbloat\fR size, not object size. If a percentage is given, the threshold will apply to the bloat size compared to the table + \s-1TOAST\s0 size. If multiple threshold values are passed, check_pgactivity will choose the largest (bloat size) value. .Sp This service supports both \f(CW\*(C`\-\-dbexclude\*(C'\fR and \f(CW\*(C`\-\-dbinclude\*(C'\fR parameters. The 'postgres' database and templates are always excluded. .Sp This service supports a \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameter to exclude relations matching the given regular expression. The regular expression applies to \&\*(L"database.schema_name.relation_name\*(R". This enables you to filter either on a relation name for all schemas and databases, on a qualified named relation (schema + relation) for all databases or on a qualified named relation in only one database. .Sp You can use multiple \f(CW\*(C`\-\-exclude REGEX\*(C'\fR parameters. .Sp \&\fBWarning\fR: With a non-superuser role, this service can only check the tables that the given role is granted to read! .Sp Perfdata will return the number of tables matching the warning and critical thresholds, per database. .Sp A list of the bloated tables will be returned after the perfdata. This list contains the fully qualified bloated table name, the estimated bloat size, the table size and the bloat percentage. .Sp Required privileges: superuser (<10) able to log in all databases, or at least those in \f(CW\*(C`\-\-dbinclude\*(C'\fR; superuser (<10); on PostgreSQL 10+, a user with the role pg_monitor suffices, provided that you grant \s-1SELECT\s0 on the system table pg_statistic to the pg_monitor role, in each database of the cluster: \&\f(CW\*(C`GRANT SELECT ON pg_statistic TO pg_monitor;\*(C'\fR .IP "\fBtemp_files\fR (8.1+)" 4 .IX Item "temp_files (8.1+)" Check the number and size of temp files. .Sp This service uses the status file (see \f(CW\*(C`\-\-status\-file\*(C'\fR parameter) for 9.2+. .Sp Perfdata returns the number and total size of temp files found in \&\f(CW\*(C`pgsql_tmp\*(C'\fR folders. They are aggregated by database until 8.2, then by tablespace (see \s-1GUC\s0 temp_tablespaces). .Sp Starting with 9.2, perfdata returns as well the number of temp files per database since last run, the total size of temp files per database since last run and the rate at which temp files were generated. .Sp Critical and Warning thresholds are optional. They accept either a number of file (raw value), a size (unit is \fBmandatory\fR to define a size) or both values separated by a comma. .Sp Thresholds are applied on current temp files being created \s-1AND\s0 the number/size of temp files created since last execution. .Sp Required privileges: <10: superuser v10: an unprivileged role is possible but it will not monitor databases that it cannot access, nor live temp files v11: an unprivileged role is possible but must be granted \s-1EXECUTE\s0 on functions pg_ls_dir(text), pg_read_file(text), pg_stat_file(text); the same restrictions than on v10 will still apply .IP "\fBuptime\fR (8.1+)" 4 .IX Item "uptime (8.1+)" Returns time since postmaster start (\*(L"uptime\*(R", from 8.1), since configuration reload (from 8.4), and since shared memory initialization (from 10). .Sp Please note that the uptime is unaffected when the postmaster resets all its children (for example after a kill \-9 on a process or a failure). .Sp From 10+, the 'time since shared memory init' aims at detecting this situation: in fact we use the age of the oldest non-client child process (usually checkpointer, writer or startup). This needs pg_monitor access to read pg_stat_activity. .Sp Critical and Warning thresholds are optional. If both are set, Critical is raised when the postmaster uptime or the time since shared memory initialization is less than the critical threshold. Warning is raised when the time since configuration reload is less than the warning threshold. If only a warning or critical threshold is given, it will be used for both cases. Obviously these alerts will disappear from themselves once enough time has passed. .Sp Perfdata contain the three values (when available). .Sp Required privileges: pg_monitor on \s-1PG10+\s0; otherwise unprivileged role. .IP "\fBwal_files\fR (8.1+)" 4 .IX Item "wal_files (8.1+)" Check the number of \s-1WAL\s0 files. .Sp Perfdata returns the total number of \s-1WAL\s0 files, current number of written \s-1WAL,\s0 the current number of recycled \s-1WAL,\s0 the rate of \s-1WAL\s0 written to disk since the last execution on the master cluster and the current timeline. .Sp Critical and Warning thresholds accept either a raw number of files or a percentage. In case of percentage, the limit is computed based on: .Sp .Vb 1 \& 100% = 1 + checkpoint_segments * (2 + checkpoint_completion_target) .Ve .Sp For PostgreSQL 8.1 and 8.2: .Sp .Vb 1 \& 100% = 1 + checkpoint_segments * 2 .Ve .Sp If \f(CW\*(C`wal_keep_segments\*(C'\fR is set for 9.0 to 9.4, the limit is the greatest of the following formulas: .Sp .Vb 2 \& 100% = 1 + checkpoint_segments * (2 + checkpoint_completion_target) \& 100% = 1 + wal_keep_segments + 2 * checkpoint_segments .Ve .Sp For 9.5 and above, the limit is: .Sp .Vb 2 \& 100% = max_wal_size (as a number of WAL) \& + wal_keep_segments (if set) .Ve .Sp Required privileges: <10:superuser (<10) v10:unprivileged user with pg_monitor v11:unprivileged user with pg_monitor, or with grant \s-1EXECUTE\s0 on function pg_ls_waldir .SS "\s-1EXAMPLES\s0" .IX Subsection "EXAMPLES" .ie n .IP "Execute service ""last_vacuum"" on host ""host=localhost port=5432"":" 4 .el .IP "Execute service ``last_vacuum'' on host ``host=localhost port=5432'':" 4 .IX Item "Execute service last_vacuum on host host=localhost port=5432:" .Vb 1 \& check_pgactivity \-h localhost \-p 5432 \-s last_vacuum \-w 30m \-c 1h30m .Ve .ie n .IP "Execute service ""hot_standby_delta"" between hosts ""service=pg92"" and ""service=pg92s"":" 4 .el .IP "Execute service ``hot_standby_delta'' between hosts ``service=pg92'' and ``service=pg92s'':" 4 .IX Item "Execute service hot_standby_delta between hosts service=pg92 and service=pg92s:" .Vb 1 \& check_pgactivity \-\-dbservice pg92,pg92s \-\-service hot_standby_delta \-w 32MB \-c 160MB .Ve .ie n .IP "Execute service ""streaming_delta"" on host ""service=pg92"" to check its slave ""stby1"" with the \s-1IP\s0 address ""192.168.1.11"":" 4 .el .IP "Execute service ``streaming_delta'' on host ``service=pg92'' to check its slave ``stby1'' with the \s-1IP\s0 address ``192.168.1.11'':" 4 .IX Item "Execute service streaming_delta on host service=pg92 to check its slave stby1 with the IP address 192.168.1.11:" .Vb 1 \& check_pgactivity \-\-dbservice pg92 \-\-slave "stby1 192.168.1.11" \-\-service streaming_delta \-w 32MB \-c 160MB .Ve .ie n .IP "Execute service ""hit_ratio"" on host ""slave"" port ""5433, excluding database matching the regexps ""idelone"" and ""(?i:sleep)"":" 4 .el .IP "Execute service ``hit_ratio'' on host ``slave'' port ``5433, excluding database matching the regexps ''idelone`` and ''(?i:sleep)"":" 4 .IX Item "Execute service hit_ratio on host slave port 5433, excluding database matching the regexps idelone and (?i:sleep)"":" .Vb 1 \& check_pgactivity \-p 5433 \-h slave \-\-service hit_ratio \-\-dbexclude idelone \-\-dbexclude "(?i:sleep)" \-w 90% \-c 80% .Ve .ie n .IP "Execute service ""hit_ratio"" on host ""slave"" port ""5433, only for databases matching the regexp ""importantone"":" 4 .el .IP "Execute service ``hit_ratio'' on host ``slave'' port ``5433, only for databases matching the regexp ''importantone"":" 4 .IX Item "Execute service hit_ratio on host slave port 5433, only for databases matching the regexp importantone"":" .Vb 1 \& check_pgactivity \-p 5433 \-h slave \-\-service hit_ratio \-\-dbinclude importantone \-w 90% \-c 80% .Ve .SH "VERSION" .IX Header "VERSION" check_pgactivity version 2.4, released on Wed Jan 30 2019 .SH "LICENSING" .IX Header "LICENSING" This program is open source, licensed under the PostgreSQL license. For license terms, see the \s-1LICENSE\s0 provided with the sources. .SH "AUTHORS" .IX Header "AUTHORS" Author: Open PostgreSQL Monitoring Development Group Copyright: (C) 2012\-2018 Open PostgreSQL Monitoring Development Group