From 801821cdad991a0c5a76f79bd204d921f3f56106 Mon Sep 17 00:00:00 2001
From: Ruslan Kabalin NAGIOS EXAMPLES
Copyright (c) 2007-2013 Greg Sabino Mullane <greg@endpoint.com>.
+Copyright (c) 2007-2015 Greg Sabino Mullane <greg@endpoint.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From 4cea93ea51fceb532c4b07b70c18eeb412aaeed7 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane-Date: Tue, 26 May 2015 22:02:30 -0400 Subject: [PATCH 017/272] Remove tabs, cleanup whitespace --- check_postgres.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index f8da6b8a..a7a2a767 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -2254,10 +2254,10 @@ sub run_command { if ($arg->{dbnumber} and $arg->{dbnumber} != $num) { next; } - ## Likewise if we have specified "target" database info and this is not our choice - if ($arg->{target} and $arg->{target} != $db) { + ## Likewise if we have specified "target" database info and this is not our choice + if ($arg->{target} and $arg->{target} != $db) { next; - } + } ## Just to keep things clean: truncate $tempfh, 0; @@ -7295,9 +7295,9 @@ sub check_sequence { FROM $seqname) foo }; } - # Use UNION ALL to query multiple sequences at once, however if there are too many sequences this can exceed + # Use UNION ALL to query multiple sequences at once, however if there are too many sequences this can exceed # maximum argument length; so split into chunks of 200 sequences or less and iterate over them. - while (my @seq_sql_chunk = splice @seq_sql, 0, 200) { + while (my @seq_sql_chunk = splice @seq_sql, 0, 200) { my $seqinfo = run_command(join("\nUNION ALL\n", @seq_sql_chunk), { target => $db }); # execute all SQL commands at once for my $r2 (@{$seqinfo->{db}[0]{slurp}}) { # now look at all results my ($seqname, $last, $slots, $used, $percent, $left) = @$r2{qw/ seqname last_value slots used percent numleft / }; @@ -7322,7 +7322,7 @@ sub check_sequence { push @warn => $msg; } } - } + } if ($MRTG) { my $msg = join ' | ' => map { $_->[0] } @{$seqinfo{$maxp}}; do_mrtg({one => $maxp, msg => $msg}); From 776408aab47f29e4f7f47bf4d515671d7736ab08 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Tue, 23 Jun 2015 09:09:07 -0400 Subject: [PATCH 018/272] Version bump. --- check_postgres.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_postgres.pl b/check_postgres.pl index a7a2a767..df143576 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -32,7 +32,7 @@ package check_postgres; binmode STDOUT, ':encoding(UTF-8)'; -our $VERSION = '2.21.0'; +our $VERSION = '2.21.1'; use vars qw/ %opt $PGBINDIR $PSQL $res $COM $SQL $db /; From 51c6991862c9b24da0bfaa5917c1597db12ff495 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Tue, 23 Jun 2015 09:16:26 -0400 Subject: [PATCH 019/272] Update release notes a bit --- check_postgres.pl | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index df143576..42f1ab07 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -7974,7 +7974,7 @@ =head1 NAME B - a Postgres monitoring script for Nagios, MRTG, Cacti, and others -This documents describes check_postgres.pl version 2.21.0 +This documents describes check_postgres.pl version 2.21.1 =head1 SYNOPSIS @@ -9832,20 +9832,44 @@ =head1 HISTORY Add explicit ORDER BY to the slony_status check to get the most lagged server. (Jeff Frost) - Declare POD encoding to be utf8. (Christoph Berg) + Change the way tables are quoted in replicate_row. + (Glyn Astill) - Query all sequences per DB in parallel for action=sequence. (Christoph Berg) + Improved multi-slave support in replicate_row. + (Andrew Yochum) + + Add xact timestamp support to hot_standby_delay. + Allow the hot_standby_delay check to accept xlog byte position or + timestamp lag intervals as thresholds, or even both at the same time. + (Josh Williams) + + Fix and extend hot_standby_delay documentation + (Michael Renner) + + Don't swallow space before the -c flag when reporting errors + (Jeff Janes) + + Show actual long-running query in query_time output + (Peter Eisentraut) + + Declare POD encoding to be utf8. + (Christoph Berg) + + Query all sequences per DB in parallel for action=sequence. + (Christoph Berg) =item B September 24, 2013 Fix issue with SQL steps in check_pgagent_jobs for sql steps which perform deletes (Rob Emery via github pull) - Install man page in section 1. (Peter Eisentraut, bug 53, github issue 26) + Install man page in section 1. + (Peter Eisentraut, bug 53, github issue 26) Order lock types in check_locks output to make the ordering predictable; setting SKIP_NETWORK_TESTS will skip the new_version tests; other minor test - suite fixes. (Christoph Berg) + suite fixes. + (Christoph Berg) Fix same_schema check on 9.3 by ignoring relminmxid differences in pg_class (Christoph Berg) From 791a17ff1b662b1b6d4d3e5261bfdc3aac313731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Tue, 23 Jun 2015 16:26:10 +0200 Subject: [PATCH 020/272] Fix t/02_sequence.t for PG 9.0/1 --- t/02_sequence.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/02_sequence.t b/t/02_sequence.t index efce3a02..1111d895 100644 --- a/t/02_sequence.t +++ b/t/02_sequence.t @@ -118,7 +118,7 @@ if ($ver >= 90200) { like ($cp->run('--exclude=sequence_test_id_seq'), qr{WARNING:.+public.sequence_test_smallid_seq=92% \(calls left=2767\)}, $t); } else { SKIP: { - skip '"smallserial" needs PostgreSQL 9.2 or later', 2; + skip '"smallserial" needs PostgreSQL 9.2 or later', 1; } } From 60af9f27721d62219a5ef220feff02ae7e8b79b1 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Tue, 23 Jun 2015 16:35:31 +0200 Subject: [PATCH 021/272] Fix txn_time regression test for 9.0/9.1 Newer versions will show the last or current query here, older versions will just show " in transaction" if there is currently no query running. --- t/02_txn_time.t | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/02_txn_time.t b/t/02_txn_time.t index 8be2fa18..d743fe1f 100644 --- a/t/02_txn_time.t +++ b/t/02_txn_time.t @@ -76,7 +76,8 @@ sleep(1); like ($cp->run(q{-w 0}), qr{longest txn: 1s}, $t); $t .= ' (MRTG)'; -like ($cp->run(q{--output=mrtg -w 0}), qr{\d+\n0\n\nPID:\d+ database:$dbname username:\w+ query:SELECT 1\n}, $t); +my $query_patten = ($ver >= 90200) ? "SELECT 1" : " in transaction"; +like ($cp->run(q{--output=mrtg -w 0}), qr{\d+\n0\n\nPID:\d+ database:$dbname username:\w+ query:$query_patten\n}, $t); $idle_dbh->commit; From efcff69ea7678ec264e814b3e515a09d1674db87 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Fri, 26 Jun 2015 08:52:32 -0400 Subject: [PATCH 022/272] Rearrange recent changes in rough priority order --- check_postgres.pl | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index 42f1ab07..6bb63d31 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -9826,38 +9826,38 @@ =head1 HISTORY =item B + Add xact timestamp support to hot_standby_delay. + Allow the hot_standby_delay check to accept xlog byte position or + timestamp lag intervals as thresholds, or even both at the same time. + (Josh Williams) + + Query all sequences per DB in parallel for action=sequence. + (Christoph Berg) + Fix bloat check to use correct SQL depending on the server version. (Adrian Vondendriesch) + Show actual long-running query in query_time output + (Peter Eisentraut) + Add explicit ORDER BY to the slony_status check to get the most lagged server. (Jeff Frost) - Change the way tables are quoted in replicate_row. - (Glyn Astill) - Improved multi-slave support in replicate_row. (Andrew Yochum) - Add xact timestamp support to hot_standby_delay. - Allow the hot_standby_delay check to accept xlog byte position or - timestamp lag intervals as thresholds, or even both at the same time. - (Josh Williams) - - Fix and extend hot_standby_delay documentation - (Michael Renner) + Change the way tables are quoted in replicate_row. + (Glyn Astill) Don't swallow space before the -c flag when reporting errors (Jeff Janes) - Show actual long-running query in query_time output - (Peter Eisentraut) + Fix and extend hot_standby_delay documentation + (Michael Renner) Declare POD encoding to be utf8. (Christoph Berg) - Query all sequences per DB in parallel for action=sequence. - (Christoph Berg) - =item B September 24, 2013 Fix issue with SQL steps in check_pgagent_jobs for sql steps which perform deletes From d2412d5125ac991252f09ddf0aac17674feec10d Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Fri, 26 Jun 2015 09:18:02 -0400 Subject: [PATCH 023/272] Spelling --- check_postgres.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index 6bb63d31..2fd53ec4 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -8857,7 +8857,7 @@ =head2 B to it. The slave server must be in hot_standby (e.g. read only) mode, therefore the minimum version to use this action is Postgres 9.0. The I<--warning> and I<--critical> options are the delta between the xlog locations. Since these values are byte offsets in the WAL they should match the expected transaction volume -of your application to prevent false postives or negatives. +of your application to prevent false positives or negatives. The first "--dbname", "--host", and "--port", etc. options are considered the master; the second belongs to the slave. @@ -8869,7 +8869,7 @@ =head2 B form 'I and I
$opt{showtime}
is set to true, which is the default)The settings_checksum action requires the Digest::MD5 module.
-The checkpoint action requires the Date::Parse module.
-Some actions require access to external programs. If psql is not explicitly
-specified, the command which
is used to find it. The program /bin/df
-is needed by the disk_space action.
-
-Development happens using the git system. You can clone the latest version by doing:
-- git clone git://bucardo.org/check_postgres.git-
-
-Three mailing lists are available. For discussions about the program, bug reports, -feature requests, and commit notices, send email to check_postgres@bucardo.org
-https://mail.endcrypt.com/mailman/listinfo/check_postgres
-A low-volume list for announcement of new versions and important notices is the -'check_postgres-announce' list:
-https://mail.endcrypt.com/mailman/listinfo/check_postgres-announce
-Source code changes (via git-commit) are sent to the -'check_postgres-commit' list:
-https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit
--
-Items not specifically attributed are by GSM (Greg Sabino Mullane).
- Fix issue with SQL steps in check_pgagent_jobs for sql steps which perform deletes
+ (Rob Emery via github pull)
+
+ Install man page in section 1.
+ (Peter Eisentraut, bug 53, github issue 26)
--
-
- Fix issue with SQL steps in check_pgagent_jobs for sql steps which perform deletes
- (Rob Emery via github pull)
-
- Install man page in section 1. (Peter Eisentraut, bug 53, github issue 26)
-
Order lock types in check_locks output to make the ordering predictable;
setting SKIP_NETWORK_TESTS will skip the new_version tests; other minor test
- suite fixes. (Christoph Berg)
-
+ suite fixes.
+ (Christoph Berg)
+
Fix same_schema check on 9.3 by ignoring relminmxid differences in pg_class
- (Christoph Berg)
-
-- Version 2.20.1 June 24, 2013
+ (Christoph Berg)
+- Make connection check failures return CRITICAL not UNKNOWN - (Dominic Hargreaves)-
+ +-Make connection check failures return CRITICAL not UNKNOWN + (Dominic Hargreaves) + Fix --reverse option when using string comparisons in custom queries - (Nathaniel Waisbrot)
- Compute correct 'totalwastedbytes' in the bloat query - (Michael Renner)-+ (Nathaniel Waisbrot) + + Compute correct 'totalwastedbytes' in the bloat query + (Michael Renner) + Do not use pg_stats "inherited" column in bloat query, if the - database is 8.4 or older. (Greg Sabino Mullane, per bug 121)-+ database is 8.4 or older. (Greg Sabino Mullane, per bug 121) + Remove host reordering in hot_standby_delay check - (Josh Williams, with help from Jacobo Blasco)-+ (Josh Williams, with help from Jacobo Blasco) + Better output for the "simple" flag - (Greg Sabino Mullane)-- Force same_schema to ignore the 'relallvisible' column - (Greg Sabino Mullane)-
- Add check for pgagent jobs (David E. Wheeler)-
+ +-Add check for pgagent jobs (David E. Wheeler) + Force STDOUT to use utf8 for proper output - (Greg Sabino Mullane; reported by Emmanuel Lesouef)
+ (Greg Sabino Mullane; reported by Emmanuel Lesouef) + Fixes for Postgres 9.2: new pg_stat_activity view, - and use pg_tablespace_location, (Josh Williams)-- Allow for spaces in item lists when doing same_schema.-- Allow txn_idle to work again for < 8.3 servers by switching to query_time.-+ and use pg_tablespace_location, (Josh Williams) + + Allow for spaces in item lists when doing same_schema. + + Allow txn_idle to work again for < 8.3 servers by switching to query_time. + Fix the check_bloat SQL to take inherited tables into account, - and assume 2k for non-analyzed columns. (Geert Pante)-- Cache sequence information to speed up same_schema runs.-- Fix --excludeuser in check_txn_idle (Mika Eloranta)-- Fix user clause handling in check_txn_idle (Michael van Bracht)-+ and assume 2k for non-analyzed columns. (Geert Pante) + + Cache sequence information to speed up same_schema runs. + + Fix --excludeuser in check_txn_idle (Mika Eloranta) + + Fix user clause handling in check_txn_idle (Michael van Bracht) + Adjust docs to show colon as a better separator inside args for locks - (Charles Sprickman)-- Fix undefined $SQL2 error in check_txn_idle [github issue 16] (Patric Bechtel)-- Prevent "uninitialized value" warnings when showing the port (Henrik Ahlgren)-- Do not assume everyone has a HOME [github issue 23]-
- Add the --assume-prod option (Cédric Villemain)-
- Add the cluster_id check (Cédric Villemain)-
- Improve settings_checksum and checkpoint tests (Cédric Villemain)-
+ (Charles Sprickman) + + Fix undefined $SQL2 error in check_txn_idle [github issue 16] (Patric Bechtel) + + Prevent "uninitialized value" warnings when showing the port (Henrik Ahlgren) + + Do not assume everyone has a HOME [github issue 23]+ +
Add the --assume-prod option (Cédric Villemain)
+
+ Add the cluster_id check (Cédric Villemain)
+
+ Improve settings_checksum and checkpoint tests (Cédric Villemain)
+
Do not do an inner join to pg_user when checking database size
- (Greg Sabino Mullane; reported by Emmanuel Lesouef)
-+ (Greg Sabino Mullane; reported by Emmanuel Lesouef) + Use the full path when getting sequence information for same_schema. - (Greg Sabino Mullane; reported by Cindy Wise)-
- Fix the formula for calculating xlog positions (Euler Taveira de Oliveira)-
+ (Greg Sabino Mullane; reported by Cindy Wise) + + Fix the formula for calculating xlog positions (Euler Taveira de Oliveira) + Better ordering of output for bloat check - make indexes as important - as tables (Greg Sabino Mullane; reported by Jens Wilke)-
+ as tables (Greg Sabino Mullane; reported by Jens Wilke) + Show the dbservice if it was used at top of same_schema output - (Mike Blackwell)-
- Better installation paths (Greg Sabino Mullane, per bug 53)-
- Redo the same_schema action. Use new --filter argument for all filtering. + +-Redo the same_schema action. Use new --filter argument for all filtering. Allow comparisons between any number of databases. Remove the dbname2, dbport2, etc. arguments. - Allow comparison of the same db over time.
- Swap db1 and db2 if the slave is 1 for the hot standby check (David E. Wheeler)-- Allow multiple --schema arguments for the slony_status action (GSM and Jehan-Guillaume de Rorthais)-- Fix ORDER BY in the last vacuum/analyze action (Nicolas Thauvin)-- Fix check_hot_standby_delay perfdata output (Nicolas Thauvin)-- Look in the correct place for the .ready files with the archive_ready action (Nicolas Thauvin)-- New action: commitratio (Guillaume Lelarge)-- New action: hitratio (Guillaume Lelarge)-- Make sure --action overrides the symlink naming trick.-- Set defaults for archive_ready and wal_files (Thomas Guettler, GSM)-- Better output for wal_files and archive_ready (GSM)-- Fix warning when client_port set to empty string (bug #79)-- Account for "empty row" in -x output (i.e. source of functions).-- Fix some incorrectly named data fields (Andy Lester)-- Expand the number of pgbouncer actions (Ruslan Kabalin)-+ Allow comparison of the same db over time. + + Swap db1 and db2 if the slave is 1 for the hot standby check (David E. Wheeler) + + Allow multiple --schema arguments for the slony_status action (GSM and Jehan-Guillaume de Rorthais) + + Fix ORDER BY in the last vacuum/analyze action (Nicolas Thauvin) + + Fix check_hot_standby_delay perfdata output (Nicolas Thauvin) + + Look in the correct place for the .ready files with the archive_ready action (Nicolas Thauvin) + + New action: commitratio (Guillaume Lelarge) + + New action: hitratio (Guillaume Lelarge) + + Make sure --action overrides the symlink naming trick. + + Set defaults for archive_ready and wal_files (Thomas Guettler, GSM) + + Better output for wal_files and archive_ready (GSM) + + Fix warning when client_port set to empty string (bug #79) + + Account for "empty row" in -x output (i.e. source of functions). + + Fix some incorrectly named data fields (Andy Lester) + + Expand the number of pgbouncer actions (Ruslan Kabalin) + Give detailed information and refactor txn_idle, txn_time, and query_time - (Per request from bug #61)-- Set maxalign to 8 in the bloat check if box identified as '64-bit' - (Michel Sijmons, bug #66)-+ (Per request from bug #61) + + Set maxalign to 8 in the bloat check if box identified as '64-bit' + (Michel Sijmons, bug #66) + Support non-standard version strings in the bloat check. - (Michel Sijmons and Gurjeet Singh, bug #66)-- Do not show excluded databases in some output (Ruslan Kabalin)-- Allow "and", "or" inside arguments (David E. Wheeler)-- Add the "new_version_box" action.-- Fix psql version regex (Peter Eisentraut, bug #69)-- Add the --assume-standby-mode option (Ruslan Kabalin)-- Note that txn_idle and query_time require 8.3 (Thomas Guettler)-- Standardize and clean up all perfdata output (bug #52)-- Exclude "idle in transaction" from the query_time check (bug #43)-- Fix the perflimit for the bloat action (bug #50)-- Clean up the custom_query action a bit.-- Fix space in perfdata for hot_standby_delay action (Nicolas Thauvin)-- Handle undef percents in check_fsm_relations (Andy Lester)-- Fix typo in dbstats action (Stas Vitkovsky)-- Fix MRTG for last vacuum and last_analyze actions.-
- Add new action 'hot_standby_delay' (Nicolas Thauvin) + (Michel Sijmons and Gurjeet Singh, bug #66) + + Do not show excluded databases in some output (Ruslan Kabalin) + + Allow "and", "or" inside arguments (David E. Wheeler) + + Add the "new_version_box" action. + + Fix psql version regex (Peter Eisentraut, bug #69) + + Add the --assume-standby-mode option (Ruslan Kabalin) + + Note that txn_idle and query_time require 8.3 (Thomas Guettler) + + Standardize and clean up all perfdata output (bug #52) + + Exclude "idle in transaction" from the query_time check (bug #43) + + Fix the perflimit for the bloat action (bug #50) + + Clean up the custom_query action a bit. + + Fix space in perfdata for hot_standby_delay action (Nicolas Thauvin) + + Handle undef percents in check_fsm_relations (Andy Lester) + + Fix typo in dbstats action (Stas Vitkovsky) + + Fix MRTG for last vacuum and last_analyze actions.+ +
Add new action 'hot_standby_delay' (Nicolas Thauvin)
Add cache-busting for the version-grabbing utilities.
Fix problem with going to next method for new_version_pg
(Greg Sabino Mullane, reported by Hywel Mallett in bug #65)
Allow /usr/local/etc as an alternative location for the
check_postgresrc file (Hywel Mallett)
Do not use tgisconstraint in same_schema if Postgres >= 9
- (Guillaume Lelarge)
-- Fix warning when using symlinks - (Greg Sabino Mullane, reported by Peter Eisentraut in bug #63)
- Show OK for no matching txn_idle entries.-
Fix warning when using symlinks
+ (Greg Sabino Mullane, reported by Peter Eisentraut in bug #63)
+
+
+- Better formatting of sizes in the bloat action output.-
- Remove duplicate perfs in bloat action output.+ +
Show OK for no matching txn_idle entries.
+
Better formatting of sizes in the bloat action output.
+ Remove duplicate perfs in bloat action output.
+
+- Fix problem when examining items in pg_settings (Greg Sabino Mullane)-
+ +-Fix problem when examining items in pg_settings (Greg Sabino Mullane) + For connection test, return critical, not unknown, on FATAL errors - (Greg Sabino Mullane, reported by Peter Eisentraut in bug #62)
- Add --quiet argument to suppress output on OK Nagios results + +-Add --quiet argument to suppress output on OK Nagios results Add index comparison for same_schema (Norman Yamada and Greg Sabino Mullane) Use $ENV{PGSERVICE} instead of "service=" to prevent problems (Guillaume Lelarge) Add --man option to show the entire manual. (Andy Lester) @@ -2025,190 +1782,190 @@
HISTORY
Fix error in custom logic (Andreas Mager) Add the "pgbouncer_checksum" action (Guillaume Lelarge) Fix regex to work on WIN32 for check_fsm_relations and check_fsm_pages (Luke Koops) - Don't apply a LIMIT when using --exclude on the bloat action (Marti Raudsepp) + Don't apply a LIMIT when using --exclude on the bloat action (Marti Raudsepp) Change the output of query_time to show pid,user,port, and address (Giles Westwood) Fix to show database properly when using slony_status (Guillaume Lelarge) Allow warning items for same_schema to be comma-separated (Guillaume Lelarge) Constraint definitions across Postgres versions match better in same_schema. Work against "EnterpriseDB" databases (Sivakumar Krishnamurthy and Greg Sabino Mullane) Separate perfdata with spaces (Jehan-Guillaume (ioguix) de Rorthais) - Add new action "archive_ready" (Jehan-Guillaume (ioguix) de Rorthais)
- Allow slony_status action to handle more than one slave. - Use commas to separate function args in same_schema output (Robert Treat)
- Change autovac_freeze default warn/critical back to 90%/95% (Robert Treat) - Put all items one-per-line for relation size actions if --verbose=1+ +
Allow slony_status action to handle more than one slave.
+ Use commas to separate function args in same_schema output (Robert Treat)
+
Change autovac_freeze default warn/critical back to 90%/95% (Robert Treat)
+ Put all items one-per-line for relation size actions if --verbose=1
+- Don't use $^T in logfile check, as script may be long-running + +-Don't use $^T in logfile check, as script may be long-running Change the error string for the logfile action for easier exclusion - by programs like tail_n_mail
- Added the 'slony_status' action. - Changed the logfile sleep from 0.5 to 1, as 0.5 gets rounded to 0 on some boxes!
- Allow timeout option to be used for logtime 'sleep' time.+ +
Added the 'slony_status' action.
+ Changed the logfile sleep from 0.5 to 1, as 0.5 gets rounded to 0 on some boxes!
+
Allow timeout option to be used for logtime 'sleep' time.
+
+- Show offending database for query_time action. + +-Show offending database for query_time action. Apply perflimit to main output for sequence action. - Add 'noowner' option to same_schema action. - Raise sleep timeout for logfile check to 15 seconds.
- Fix bug preventing column constraint differences from 2 > 1 for same_schema from being shown. - Allow aliases 'dbname1', 'dbhost1', 'dbport1',etc. + +-Fix bug preventing column constraint differences from 2 > 1 for same_schema from being shown. + Allow aliases 'dbname1', 'dbhost1', 'dbport1',etc. Added "nolanguage" as a filter for the same_schema option. - Don't track "generic" table constraints (e.. $1, $2) using same_schema
- Allow "nofunctions" as a filter for the same_schema option. + +-Allow "nofunctions" as a filter for the same_schema option. Added "noperm" as a filter for the same_schema option. - Ignore dropped columns when considered positions for same_schema (Guillaume Lelarge)
- Change autovac_freeze default warn/critical from 90%/95% to 105%/120% (Marti Raudsepp)
Change autovac_freeze default warn/critical from 90%/95% to 105%/120% (Marti Raudsepp)
+
+- Allow the temporary directory to be specified via the "tempdir" argument, + +-Allow the temporary directory to be specified via the "tempdir" argument, for systems that need it (e.g. /tmp is not owned by root). Fix so old versions of Postgres (< 8.0) use the correct default database (Giles Westwood) For "same_schema" trigger mismatches, show the attached table. Add the new_version_bc check for Bucardo version checking. Add database name to perf output for last_vacuum|analyze (Guillaume Lelarge) - Fix for bloat action against old versions of Postgres without the 'block_size' param.
- Proper Nagios output for last_vacuum|analyze actions. (Cédric Villemain) - Proper Nagios output for locks action. (Cédric Villemain) - Proper Nagios output for txn_wraparound action. (Cédric Villemain) + +-Proper Nagios output for last_vacuum|analyze actions. (Cédric Villemain) + Proper Nagios output for locks action. (Cédric Villemain) + Proper Nagios output for txn_wraparound action. (Cédric Villemain) Fix for constraints with embedded newlines for same_schema. - Allow --exclude for all items when using same_schema.
- Add Nagios perf output to the wal_files check (Cédric Villemain) + +-Add Nagios perf output to the wal_files check (Cédric Villemain) Add support for .check_postgresrc, per request from Albe Laurenz. Allow list of web fetch methods to be changed with the --get_method option. Add support for the --language argument, which overrides any ENV. Add the --no-check_postgresrc flag. Ensure check_postgresrc options are completely overridden by command-line options. - Fix incorrect warning > critical logic in replicate_rows (Glyn Astill)
- For same_schema, compare view definitions, and compare languages. + +-For same_schema, compare view definitions, and compare languages. Make script into a global executable via the Makefile.PL file. Better output when comparing two databases. - Proper Nagios output syntax for autovac_freeze and backends checks (Cédric Villemain)
- Don't use a LIMIT in check_bloat if --include is used. Per complaint from Jeff Frost.
- More French translations (Guillaume Lelarge)-
Don't use a LIMIT in check_bloat if --include is used. Per complaint from Jeff Frost.
+
+
+- Quote dbname in perf output for the backends check. (Davide Abrigo) - Add 'fetch' as an alternative method for new_version checks, as this - comes by default with FreeBSD. (Hywel Mallett)+ +
More French translations (Guillaume Lelarge)
+
Quote dbname in perf output for the backends check. (Davide Abrigo)
+ Add 'fetch' as an alternative method for new_version checks, as this
+ comes by default with FreeBSD. (Hywel Mallett)
+- Allow dots and dashes in database name for the backends check (Davide Abrigo) - Check and display the database for each match in the bloat check (Cédric Villemain) - Handle 'too many connections' FATAL error in the backends check with a critical, - rather than a generic error (Greg, idea by Jürgen Schulz-Brüssel) + +-Allow dots and dashes in database name for the backends check (Davide Abrigo) + Check and display the database for each match in the bloat check (Cédric Villemain) + Handle 'too many connections' FATAL error in the backends check with a critical, + rather than a generic error (Greg, idea by Jürgen Schulz-Brüssel) Do not allow perflimit to interfere with exclusion rules in the vacuum and - analyze tests. (Greg, bug reported by Jeff Frost)
- Fix for multiple databases with the check_bloat action (Mark Kirkwood) + +-Fix for multiple databases with the check_bloat action (Mark Kirkwood) Fixes and improvements to the same_schema action (Jeff Boes) - Write tests for same_schema, other minor test fixes (Jeff Boes)
- Added the same_schema action (Greg)
- Added timeout via statement_timeout in addition to perl alarm (Greg)+ +
Added the same_schema action (Greg)
+
Added timeout via statement_timeout in addition to perl alarm (Greg)
+- Added internationalization support (Greg) - Added the 'disabled_triggers' check (Greg) - Added the 'prepared_txns' check (Greg) - Added the 'new_version_cp' and 'new_version_pg' checks (Greg) + +-Added internationalization support (Greg) + Added the 'disabled_triggers' check (Greg) + Added the 'prepared_txns' check (Greg) + Added the 'new_version_cp' and 'new_version_pg' checks (Greg) French translations (Guillaume Lelarge) Make the backends search return ok if no matches due to inclusion rules, per report by Guillaume Lelarge (Greg) Added comprehensive unit tests (Greg, Jeff Boes, Selena Deckelmann) Make fsm_pages and fsm_relations handle 8.4 servers smoothly. (Greg) - Fix missing 'upd' field in show_dbstats (Andras Fabian) + Fix missing 'upd' field in show_dbstats (Andras Fabian) Allow ENV{PGCONTROLDATA} and ENV{PGBINDIR}. (Greg) Add various Perl module infrastructure (e.g. Makefile.PL) (Greg) Fix incorrect regex in txn_wraparound (Greg) @@ -2219,510 +1976,505 @@
HISTORY
Remove --schema option from the fsm_ checks. (Greg Mullane and Robert Treat) Handle case when ENV{PGUSER} is set. (Andy Lester) Many various fixes. (Jeff Boes) - Fix --dbservice: check version and use ENV{PGSERVICE} for old versions (Cédric Villemain)
- Make the sequence action check if sequence being used for a int4 column and - react appropriately. (Michael Glaesemann)
- Fix to prevent multiple groupings if db arguments given.-
- Allow the -p argument for port to work again.-
Make the sequence action check if sequence being used for a int4 column and
+ react appropriately. (Michael Glaesemann)
-- Do not require a connection argument, but use defaults and ENV variables when - possible: PGHOST, PGPORT, PGUSER, PGDATABASE.
Fix to prevent multiple groupings if db arguments given.
+
+- Only require Date::Parse to be loaded if using the checkpoint action.+ +
Allow the -p argument for port to work again.
+
Do not require a connection argument, but use defaults and ENV variables when
+ possible: PGHOST, PGPORT, PGUSER, PGDATABASE.
+- Add the 'checkpoint' action.+ +
Only require Date::Parse to be loaded if using the checkpoint action.
+
Add the 'checkpoint' action.
+
+- Better checking of $opt{dbservice} structure (Cédric Villemain) + +-Better checking of $opt{dbservice} structure (Cédric Villemain) Fix time display in timesync action output (Selena Deckelmann) - Fix documentation typos (Josh Tolley)
- Minor fix to regex in verify_version (Lee Jensen)
- Minor documentation tweak.-
- Add support for --noidle flag to prevent backends action from counting idle processes. - Patch by Selena Deckelmann.-
- Fix small undefined warning when not using --dbservice.-
Minor fix to regex in verify_version (Lee Jensen)
-- Add support for the pg_Service.conf file with the --dbservice option.
- Fix options for replicate_row action, per report from Jason Gordon.+ +
Minor documentation tweak.
+
Add support for --noidle flag to prevent backends action from counting idle processes.
+ Patch by Selena Deckelmann.
+
+ Fix small undefined warning when not using --dbservice.
+
+- Wrap File::Temp::cleanup() calls in eval, in case File::Temp is an older version. - Patch by Chris Butler.+ +
Add support for the pg_Service.conf file with the --dbservice option.
+
Fix options for replicate_row action, per report from Jason Gordon.
+
+- Cast numbers to numeric to support sequences ranges > bigint in check_sequence action. - Thanks to Scott Marlowe for reporting this.+ +
Wrap File::Temp::cleanup() calls in eval, in case File::Temp is an older version.
+ Patch by Chris Butler.
+
Cast numbers to numeric to support sequences ranges > bigint in check_sequence action.
+ Thanks to Scott Marlowe for reporting this.
+- Add Cacti support with the dbstats action. + +-Add Cacti support with the dbstats action. Pretty up the time output for last vacuum and analyze actions. - Show the percentage of backends on the check_backends action.
- Fix minor warning in action check_bloat with multiple databases. + +-Fix minor warning in action check_bloat with multiple databases. Allow warning to be greater than critical when using the --reverse option. - Support the --perflimit option for the check_sequence action.
- Minor tweak to way we store the default port.
- Allow the default port to be changed easily. - Allow transform of simple output by MB, GB, etc.-
- Allow multiple databases in 'sequence' action. Reported by Christoph Zwerschke.-
Minor tweak to way we store the default port.
-- Add missing $schema to check_fsm_pages. (Robert Treat)
- Change option 'checktype' to 'valtype' to prevent collisions with -c[ritical] - Better handling of errors.-
- Do explicit cleanups of the temp directory, per problems reported by sb@nnx.com.+
Allow the default port to be changed easily.
+ Allow transform of simple output by MB, GB, etc.
+
Allow multiple databases in 'sequence' action. Reported by Christoph Zwerschke.
+- Account for cases where some rounding queries give -0 instead of 0. - Thanks to Glyn Astill for helping to track this down.+ +
Add missing $schema to check_fsm_pages. (Robert Treat)
+
Change option 'checktype' to 'valtype' to prevent collisions with -c[ritical]
+ Better handling of errors.
+
+- Always quote identifiers in check_replicate_row action.+ +
Do explicit cleanups of the temp directory, per problems reported by sb@nnx.com.
+
Account for cases where some rounding queries give -0 instead of 0.
+ Thanks to Glyn Astill for helping to track this down.
+- Give a better error if one of the databases cannot be reached.+ +
Always quote identifiers in check_replicate_row action.
+
Give a better error if one of the databases cannot be reached.
+
+- Add the "sequence" action, thanks to Gavin M. Roy for the idea. + +-Add the "sequence" action, thanks to Gavin M. Roy for the idea. Fix minor problem with autovac_freeze action when using MRTG output. Allow output argument to be case-insensitive. - Documentation fixes.
- Fix some minor typos
- Expand range of allowed names for --repinfo argument (Glyn Astill) - Documentation tweaks.-
Fix some minor typos
+
+
+- Fixes for minor output and scoping problems.+ +
Expand range of allowed names for --repinfo argument (Glyn Astill)
+ Documentation tweaks.
+
Fixes for minor output and scoping problems.
+
+- Add MRTG output to fsm_pages and fsm_relations. + +-Add MRTG output to fsm_pages and fsm_relations. Force error messages to one-line for proper Nagios output. Check for invalid prereqs on failed command. From conversations with Euler Taveira de Oliveira. - Tweak the fsm_pages formula a little.
- Add fsm_pages and fsm_relations actions. (Robert Treat)
- Fix for race condition in txn_time action. - Add --debugoutput option.-
- Allow alternate arguments "dbhost" for "host" and "dbport" for "port". - Output a zero as default value for second line of MRTG output.-
Add fsm_pages and fsm_relations actions. (Robert Treat)
-- Fix sorting error in the "disk_space" action for non-Nagios output. - Allow --simple as a shortcut for --output=simple.
- Don't check databases with datallowconn false for the "autovac_freeze" action.-
Fix for race condition in txn_time action.
+ Add --debugoutput option.
+
+
+- Add the "autovac_freeze" action, thanks to Robert Treat for the idea and design. - Put an ORDER BY on the "txn_wraparound" action.+ +
Allow alternate arguments "dbhost" for "host" and "dbport" for "port".
+ Output a zero as default value for second line of MRTG output.
+
Fix sorting error in the "disk_space" action for non-Nagios output.
+ Allow --simple as a shortcut for --output=simple.
+- Optimizations to speed up the "bloat" action quite a bit. - Fix "version" action to not always output in mrtg mode.+ +
Don't check databases with datallowconn false for the "autovac_freeze" action.
+
Add the "autovac_freeze" action, thanks to Robert Treat for the idea and design.
+ Put an ORDER BY on the "txn_wraparound" action.
+
+- Add support for MRTG and "simple" output options. - Many small improvements to nearly all actions.+ +
Optimizations to speed up the "bloat" action quite a bit.
+ Fix "version" action to not always output in mrtg mode.
+
Add support for MRTG and "simple" output options.
+ Many small improvements to nearly all actions.
+- Fix an error in the bloat SQL in 1.9.0 + +-Fix an error in the bloat SQL in 1.9.0 Allow percentage arguments to be over 99% - Allow percentages in the bloat --warning and --critical (thanks to Robert Treat for the idea)
- Don't include information_schema in certain checks. (Jeff Frost) - Allow --include and --exclude to use schemas by using a trailing period.
- Output schema name before table name where appropriate. - Thanks to Jeff Frost.-
Don't include information_schema in certain checks. (Jeff Frost)
+ Allow --include and --exclude to use schemas by using a trailing period.
+
+
+- Better detection of problems in --replicate_row.+ +
Output schema name before table name where appropriate.
+ Thanks to Jeff Frost.
+
Better detection of problems in --replicate_row.
+- Fix 'backends' action: there may be no rows in pg_stat_activity, so run a second + +-Fix 'backends' action: there may be no rows in pg_stat_activity, so run a second query if needed to find the max_connections setting. - Thanks to Jeff Frost for the bug report.
- Changes to allow working under Nagios' embedded Perl mode. (Ioannis Tambouras)
Changes to allow working under Nagios' embedded Perl mode. (Ioannis Tambouras)
+- Allow 'bloat' action to work on Postgres version 8.0. + +-Allow 'bloat' action to work on Postgres version 8.0. Allow for different commands to be run for each action depending on the server version. - Give better warnings when running actions not available on older Postgres servers.
- Add the --reverse option to the custom_query action.
- Fix 'query_time' action: account for race condition in which zero rows appear in pg_stat_activity. - Thanks to Dustin Black for the bug report.-
- Add --replicate_row action-
Add the --reverse option to the custom_query action.
-- Add --symlinks option as a shortcut to --action=rebuild_symlinks
- Add the custom_query action.-
- Fix problem with too eager creation of custom pgpass file.-
Fix 'query_time' action: account for race condition in which zero rows appear in pg_stat_activity.
+ Thanks to Dustin Black for the bug report.
-- Add example Nagios configuration settings (Brian A. Seklecki)
Add --replicate_row action
+- Add the --includeuser and --excludeuser options. Documentation cleanup.+ +
Add --symlinks option as a shortcut to --action=rebuild_symlinks
+
Add the custom_query action.
+
+- Add in the 'output' concept for future support of non-Nagios programs.+ +
Fix problem with too eager creation of custom pgpass file.
+
Add example Nagios configuration settings (Brian A. Seklecki)
+- Fix bug preventing --dbpass argument from working (Robert Treat).+ +
Add the --includeuser and --excludeuser options. Documentation cleanup.
+
Add in the 'output' concept for future support of non-Nagios programs.
+
+- Minor documentation fixes.+ +
Fix bug preventing --dbpass argument from working (Robert Treat).
+
Minor documentation fixes.
+- Have 'wal_files' action use pg_ls_dir (idea by Robert Treat). + +-Have 'wal_files' action use pg_ls_dir (idea by Robert Treat). For last_vacuum and last_analyze, respect autovacuum effects, add separate - autovacuum checks (ideas by Robert Treat).
- Have txn_idle use query_start, not xact_start.
- Add in txn_idle and txn_time actions.+ +
Have txn_idle use query_start, not xact_start.
+
Add in txn_idle and txn_time actions.
+
+- Add the 'wal_files' action, which counts the number of WAL files + +-Add the 'wal_files' action, which counts the number of WAL files in your pg_xlog directory. Fix some typos in the docs. Explicitly allow -v as an argument. - Allow for a null syslog_facility in the 'logfile' action.
- Fix error preventing --action=rebuild_symlinks from working.
- Switch vacuum and analyze date output to use 'DD', not 'D'. (Glyn Astill)+ +
Fix error preventing --action=rebuild_symlinks from working.
+
Switch vacuum and analyze date output to use 'DD', not 'D'. (Glyn Astill)
+- Fixes, enhancements, and performance tracking. + +-Fixes, enhancements, and performance tracking. Add performance data tracking via --showperf and --perflimit Lots of refactoring and cleanup of how actions handle arguments. - Do basic checks to figure out syslog file for 'logfile' action. - Allow for exact matching of beta versions with 'version' action. - Redo the default arguments to only populate when neither 'warning' nor 'critical' is provided. - Allow just warning OR critical to be given for the 'timesync' action. - Remove 'redirect_stderr' requirement from 'logfile' due to 8.3 changes. - Actions 'last_vacuum' and 'last_analyze' are 8.2 only (Robert Treat)
- First public release, December 2007+ +
First public release, December 2007
+
-
-The index bloat size optimization is rough.
+Some actions may not work on older versions of Postgres (before 8.0).
-Please report any problems to check_postgres@bucardo.org
--
-Greg Sabino Mullane <greg@endpoint.com>
--
-Please report any problems to check_postgres@bucardo.org
+ +Greg Sabino Mullane <greg@endpoint.com>
+ +Some example Nagios configuration settings using this script:
-- define command { + ++ +-define command { command_name check_postgres_size command_line $USER2$/check_postgres.pl -H $HOSTADDRESS$ -u pgsql -db postgres --action database_size -w $ARG1$ -c $ARG2$ - }
+ } + define command { command_name check_postgres_locks command_line $USER2$/check_postgres.pl -H $HOSTADDRESS$ -u pgsql -db postgres --action locks -w $ARG1$ -c $ARG2$ - }-+ } + + define service { use generic-other host_name dbhost.gtld service_description dbhost PostgreSQL Service Database Usage Size check_command check_postgres_size!256000000!512000000 - }-+ } + define service { use generic-other host_name dbhost.gtld service_description dbhost PostgreSQL Service Database Locks check_command check_postgres_locks!2!3 - }--
-
-LICENSE AND COPYRIGHT
-Copyright (c) 2007-2015 Greg Sabino Mullane <greg@endpoint.com>.
-Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met:
-- 1. Redistributions of source code must retain the above copyright notice, + }+ +LICENSE AND COPYRIGHT
+ +Copyright (c) 2007-2015 Greg Sabino Mullane <greg@endpoint.com>.
+ +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ +-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY -OF SUCH DAMAGE.
+ and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ + + From d75f10a1074b8dee8eca1ff583fb02b200a72e01 Mon Sep 17 00:00:00 2001 From: Greg Sabino MullaneThis file contains a simple list of connection options. You can also pass additional information when using this option such as --dbservice="maindatabase sslmode=require"
-The documentation for this file can be found at http://www.postgresql.org/docs/current/static/libpq-pgservice.html
+The documentation for this file can be found at https://www.postgresql.org/docs/current/static/libpq-pgservice.html
@@ -1285,7 +1285,7 @@(symlink: check_postgres_txn_wraparound
) Checks how close to transaction wraparound one or more databases are getting. The --warning and --critical options indicate the number of transactions done, and must be a positive integer. If either option is not given, the default values of 1.3 and 1.4 billion are used. There is no need to run this command more than once per database cluster. For a more detailed discussion of what this number represents and what to do about it, please visit the page http://www.postgresql.org/docs/current/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
(symlink: check_postgres_txn_wraparound
) Checks how close to transaction wraparound one or more databases are getting. The --warning and --critical options indicate the number of transactions done, and must be a positive integer. If either option is not given, the default values of 1.3 and 1.4 billion are used. There is no need to run this command more than once per database cluster. For a more detailed discussion of what this number represents and what to do about it, please visit the page https://www.postgresql.org/docs/current/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
The warning and critical values can have underscores in the number for legibility, as Perl does.
From 51acc620d4a015c47e09d95b4c639284ec10d645 Mon Sep 17 00:00:00 2001 From: Christoph Bergcheck_postgres.pl - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.22.0
+This documents describes check_postgres.pl version 2.22.1
(symlink: check_postgres_archive_ready
) Checks how many WAL files with extension .ready exist in the pg_xlog/archive_status directory, which is found off of your data_directory. This action must be run as a superuser, in order to access the contents of the pg_xlog/archive_status directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of .ready files in the pg_xlog/archive_status directory. Usually, these values should be low, turning on the archive mechanism, we usually want it to archive WAL files as fast as possible.
(symlink: check_postgres_archive_ready
) Checks how many WAL files with extension .ready exist in the pg_xlog/archive_status directory, which is found off of your data_directory. If the --lsfunc option is not used then this action must be run as a superuser, in order to access the contents of the pg_xlog/archive_status directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of .ready files in the pg_xlog/archive_status directory. Usually, these values should be low, turning on the archive mechanism, we usually want it to archive WAL files as fast as possible.
If the archive command fail, number of WAL in your pg_xlog directory will grow until exhausting all the disk space and force PostgreSQL to stop immediately.
-Example 1: Check that the number of ready WAL files is 10 or less on host "pluto"
+To avoid connecting as a database superuser, a wrapper function around pg_ls_dir()
should be defined as a superuser with SECURITY DEFINER, and the --lsfunc option used. This example function, if defined by a superuser, will allow the script to connect as a normal user nagios with --lsfunc=ls_archive_status_dir
check_postgres_archive_ready --host=pluto --critical=10
+ BEGIN;
+ CREATE FUNCTION ls_archive_status_dir()
+ RETURNS SETOF TEXT
+ AS $$ SELECT pg_ls_dir('pg_xlog/archive_status') $$
+ LANGUAGE SQL
+ SECURITY DEFINER;
+ REVOKE ALL ON FUNCTION ls_archive_status_dir() FROM PUBLIC;
+ GRANT EXECUTE ON FUNCTION ls_archive_status_dir() to nagios;
+ COMMIT;
+
+Example 1: Check that the number of ready WAL files is 10 or less on host "pluto", using a wrapper function ls_archive_status_dir
to avoid the need for superuser permissions
check_postgres_archive_ready --host=pluto --critical=10 --lsfunc=ls_archive_status_dir
For MRTG output, reports the number of ready WAL files on line 1.
@@ -1158,6 +1170,8 @@To replace the old stored file with the new version, use the --replace argument.
+If you need to write the stored file to a specific direectory, use the --audit-file-dir argument.
+To enable snapshots at various points in time, you can use the "--suffix" argument to make the filenames unique to each run. See the examples below.
Example 1: Verify that two databases on hosts star and line are the same:
@@ -1315,13 +1329,25 @@(symlink: check_postgres_wal_files
) Checks how many WAL files exist in the pg_xlog directory, which is found off of your data_directory, sometimes as a symlink to another physical disk for performance reasons. This action must be run as a superuser, in order to access the contents of the pg_xlog directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of files in the pg_xlog directory. What number to set this to will vary, but a general guideline is to put a number slightly higher than what is normally there, to catch problems early.
(symlink: check_postgres_wal_files
) Checks how many WAL files exist in the pg_xlog directory, which is found off of your data_directory, sometimes as a symlink to another physical disk for performance reasons. If the --lsfunc option is not used then this action must be run as a superuser, in order to access the contents of the pg_xlog directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of files in the pg_xlog directory. What number to set this to will vary, but a general guideline is to put a number slightly higher than what is normally there, to catch problems early.
Normally, WAL files are closed and then re-used, but a long-running open transaction, or a faulty archive_command script, may cause Postgres to create too many files. Ultimately, this will cause the disk they are on to run out of space, at which point Postgres will shut down.
-Example 1: Check that the number of WAL files is 20 or less on host "pluto"
+To avoid connecting as a database superuser, a wrapper function around pg_ls_dir()
should be defined as a superuser with SECURITY DEFINER, and the --lsfunc option used. This example function, if defined by a superuser, will allow the script to connect as a normal user nagios with --lsfunc=ls_xlog_dir
check_postgres_wal_files --host=pluto --critical=20
+ BEGIN;
+ CREATE FUNCTION ls_xlog_dir()
+ RETURNS SETOF TEXT
+ AS $$ SELECT pg_ls_dir('pg_xlog') $$
+ LANGUAGE SQL
+ SECURITY DEFINER;
+ REVOKE ALL ON FUNCTION ls_xlog_dir() FROM PUBLIC;
+ GRANT EXECUTE ON FUNCTION ls_xlog_dir() to nagios;
+ COMMIT;
+
+Example 1: Check that the number of ready WAL files is 10 or less on host "pluto", using a wrapper function ls_xlog_dir
to avoid the need for superuser permissions
check_postgres_archive_ready --host=pluto --critical=10 --lsfunc=ls_xlog_dir
For MRTG output, reports the number of WAL files on line 1.
@@ -1511,7 +1537,21 @@ Add Spanish message translations
+ (Luis Vazquez)
+
+ Allow a wrapper function to run wal_files and archive_ready actions as
+ non-superuser
+ (Joshua Elsasser)
+
+ Add some defensive casting to the bloat query
+ (Greg Sabino Mullane)
+
+ Add xact timestamp support to hot_standby_delay.
From d01af7367424ed5f4e9c03a778f47e2fded62795 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut
Date: Sat, 30 Jan 2016 18:11:16 -0500
Subject: [PATCH 040/272] Call psql with option -X
Starting in PostgreSQL 9.6, psql -c no longer implies -X, so it has to
be added explicitly in order to avoid customizations in .psqlrc
interfering with the output parsing.
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 178fb376..b0433f6a 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2524,7 +2524,7 @@ sub run_command {
## Store this target in the global target list
push @{$info->{db}}, $db;
- my @args = ('-q', '-t');
+ my @args = ('-X', '-q', '-t');
if (defined $db->{dbservice} and length $db->{dbservice}) { ## XX Check for simple names
$db->{pname} = "service=$db->{dbservice}";
$ENV{PGSERVICE} = $db->{dbservice};
From cce3b95218899d2a71f9f6d5f55cafaca846380d Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Thu, 26 May 2016 14:20:56 +0200
Subject: [PATCH 041/272] Add changelog entries to close #99 and #106
---
check_postgres.pl | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index b0433f6a..2dc16b6c 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -10146,6 +10146,11 @@ =head1 HISTORY
Add some defensive casting to the bloat query
(Greg Sabino Mullane)
+ Invoke psql with option -X
+ (Peter Eisentraut)
+
+ Update postgresql.org URLs to use https.
+ (Magnus Hagander)
=item B June 30, 2015
From 00dcadc439e4e6ac239b5c3640825a809fa7725a Mon Sep 17 00:00:00 2001
From: Marco Nenciarini
Date: Tue, 12 Aug 2014 10:27:17 +0200
Subject: [PATCH 042/272] Don't fail when query contains 'disabled' word
If a query contains the disabled word (.e.g. select 1 as disabled) "check_postgres.pl --action txn_idle" exits with
```UNKNOWN: No queries - is stats_command_string or track_activities off?```
If you set track_activities to off, the status field contains 'disabled' (at least on 9.3)
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 2dc16b6c..e0950f42 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -7928,7 +7928,7 @@ sub check_txn_idle {
}
## Return unknown if stats_command_string / track_activities is off
- if ($cq =~ /disabled/o or $cq =~ //) {
+ if ($st =~ /disabled/o or $cq =~ //) {
add_unknown msg('psa-disabled');
return;
}
From 87756a5ac90b2887cf701eb7a3969b2e273b2767 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Thu, 26 May 2016 18:01:18 +0200
Subject: [PATCH 043/272] Add changelog entry for last commit, and close #72
---
check_postgres.pl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index e0950f42..56ff7bfa 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -10152,6 +10152,9 @@ =head1 HISTORY
Update postgresql.org URLs to use https.
(Magnus Hagander)
+ check_txn_idle: Don't fail when query contains 'disabled' word
+ (Marco Nenciarini)
+
=item B June 30, 2015
Add xact timestamp support to hot_standby_delay.
From c16c27e8c9bf8b5a8fea6d2c3122806bb0e7bda1 Mon Sep 17 00:00:00 2001
From: Adrien nayrat
Date: Thu, 13 Nov 2014 14:02:39 +0100
Subject: [PATCH 044/272] Correct extra space in perfdata
The extra space result in two spaces between the metrics and its incorrectly parse by centreon.
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 56ff7bfa..527ab380 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -5121,7 +5121,7 @@ sub check_hot_standby_delay {
{one => $rep_delta, two => $rec_delta});
if (defined $rep_delta) {
- $db->{perf} = sprintf ' %s=%s;%s;%s ',
+ $db->{perf} = sprintf ' %s=%s;%s;%s',
perfname(msg('hs-replay-delay')), $rep_delta, $warning, $critical;
}
if (defined $rec_delta) {
From 0a7c52a9376c974c9574ef951d3e4d55ad3a9acf Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Thu, 26 May 2016 19:42:14 +0200
Subject: [PATCH 045/272] Add changelog entry for Correct extra space in
perfdata
Close #80
---
check_postgres.pl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 527ab380..dadb542c 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -10155,6 +10155,9 @@ =head1 HISTORY
check_txn_idle: Don't fail when query contains 'disabled' word
(Marco Nenciarini)
+ check_hot_standby_delay: Correct extra space in perfdata
+ (Adrien Nayrat)
+
=item B June 30, 2015
Add xact timestamp support to hot_standby_delay.
From 6c17c3a11ac6cadc5b3880937a5871d148d60a30 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 May 2016 20:55:45 +0200
Subject: [PATCH 046/272] Change table_size to use pg_table_size()
Change table_size to use pg_table_size(), i.e. to include the TOAST
table size in the numbers reported. Add new actions indexes_size and
total_relation_size, using the respective pg_indexes_size() and
pg_total_relation_size() functions. All size checks will now also check
materialized views where applicable.
Close: #32, #83
---
check_postgres.pl | 91 ++++++++++++++++++++++++++++----------------
t/02_relation_size.t | 14 +++----
2 files changed, 66 insertions(+), 39 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index dadb542c..8704fc21 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -246,6 +246,7 @@ package check_postgres;
'relsize-msg-reli' => q{largest relation is index "$1": $2},
'relsize-msg-relt' => q{largest relation is table "$1": $2},
'relsize-msg-tab' => q{largest table is "$1": $2},
+ 'relsize-msg-indexes' => q{table with largest indexes is "$1": $2},
'rep-badarg' => q{Invalid repinfo argument: expected 6 comma-separated values},
'rep-duh' => q{Makes no sense to test replication with same values},
'rep-fail' => q{Row not replicated to slave $1},
@@ -1405,9 +1406,11 @@ package check_postgres;
fsm_relations => [1, 'Checks percentage of relations used in free space map.'],
hitratio => [0, 'Report if the hit ratio of a database is too low.'],
hot_standby_delay => [1, 'Check the replication delay in hot standby setup'],
- index_size => [0, 'Checks the size of indexes only.'],
- table_size => [0, 'Checks the size of tables only.'],
relation_size => [0, 'Checks the size of tables and indexes.'],
+ index_size => [0, 'Checks the size of indexes.'],
+ table_size => [0, 'Checks the size of tables (including TOAST).'],
+ indexes_size => [0, 'Checks the size of indexes on tables.'],
+ total_relation_size => [0, 'Checks the size of tables (including indexes and TOAST).'],
last_analyze => [0, 'Check the maximum time in seconds since any one table has been analyzed.'],
last_vacuum => [0, 'Check the maximum time in seconds since any one table has been vacuumed.'],
last_autoanalyze => [0, 'Check the maximum time in seconds since any one table has been autoanalyzed.'],
@@ -2150,10 +2153,12 @@ sub finishup {
## Check local disk_space - local means it must be run from the same box!
check_disk_space() if $action eq 'disk_space';
-## Check the size of relations, or more specifically, tables and indexes
-check_index_size() if $action eq 'index_size';
-check_table_size() if $action eq 'table_size';
-check_relation_size() if $action eq 'relation_size';
+## Check the size of relations (tables, toast tables, indexes)
+check_relation_size('relation', 'rtim') if $action eq 'relation_size';
+check_relation_size('relation', 'i') if $action eq 'index_size';
+check_relation_size('table', 'rm') if $action eq 'table_size';
+check_relation_size('indexes', 'rtm') if $action eq 'indexes_size';
+check_relation_size('total_relation', 'rm') if $action eq 'total_relation_size';
## Check how long since the last full analyze
check_last_analyze() if $action eq 'last_analyze';
@@ -6282,7 +6287,7 @@ sub check_query_time {
sub check_relation_size {
- my $relkind = shift || 'relation';
+ my ($sizefct, $relkinds) = @_;
## Check the size of one or more relations
## Supports: Nagios, MRTG
@@ -6298,21 +6303,22 @@ sub check_relation_size {
my ($warning, $critical) = validate_range({type => 'size'});
$SQL = sprintf q{
-SELECT pg_relation_size(c.oid) AS rsize,
- pg_size_pretty(pg_relation_size(c.oid)) AS psize,
+SELECT pg_%1$s_size(c.oid) AS rsize,
+ pg_size_pretty(pg_%1$s_size(c.oid)) AS psize,
relkind, relname, nspname
-FROM pg_class c, pg_namespace n WHERE (relkind = %s) AND n.oid = c.relnamespace
+FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid)
+WHERE relkind IN (%2$s)
},
- $relkind eq 'table' ? q{'r'}
- : $relkind eq 'index' ? q{'i'}
- : q{'r' OR relkind = 'i'};
+ $sizefct,
+ join (',', map { "'$_'" } split (//, $relkinds));
if ($opt{perflimit}) {
$SQL .= " ORDER BY 1 DESC LIMIT $opt{perflimit}";
}
if ($USERWHERECLAUSE) {
- $SQL =~ s/ WHERE/, pg_user u WHERE u.usesysid=c.relowner$USERWHERECLAUSE AND/;
+ $SQL =~ s/WHERE/JOIN pg_user u ON (c.relowner = u.usesysid) WHERE/;
+ $SQL .= $USERWHERECLAUSE;
}
my $info = run_command($SQL, {emptyok => 1});
@@ -6356,19 +6362,22 @@ sub check_relation_size {
}
my $msg;
- if ($relkind eq 'relation') {
- if ($kmax eq 'r') {
+ if ($action eq 'relation_size') {
+ if ($kmax =~ /[rt]/) {
$msg = msg('relsize-msg-relt', "$smax.$nmax", $pmax);
}
else {
- $msg = msg('relsize-msg-reli', $nmax, $pmax);
+ $msg = msg('relsize-msg-reli', "$smax.$nmax", $pmax);
}
}
- elsif ($relkind eq 'table') {
+ elsif ($action =~ /table|total_relation/) {
$msg = msg('relsize-msg-tab', "$smax.$nmax", $pmax);
}
+ elsif ($action eq 'indexes_size') {
+ $msg = msg('relsize-msg-indexes', "$smax.$nmax", $pmax);
+ }
else {
- $msg = msg('relsize-msg-ind', $nmax, $pmax);
+ $msg = msg('relsize-msg-ind', "$smax.$nmax", $pmax);
}
if (length $critical and $max >= $critical) {
add_critical $msg;
@@ -6386,14 +6395,6 @@ sub check_relation_size {
} ## end of check_relation_size
-sub check_table_size {
- return check_relation_size('table');
-}
-sub check_index_size {
- return check_relation_size('index');
-}
-
-
sub check_replicate_row {
## Make an update on one server, make sure it propogates to others
@@ -9173,16 +9174,35 @@ =head2 B
check_hot_standby_delay --dbhost=master,replica1 --warning='1048576 and 2 min' --critical='16777216 and 10 min'
+=head2 B
+
=head2 B
=head2 B
-=head2 B
+=head2 B
-(symlinks: C, C, and C)
-The actions B and B are simply variations of the
-B action, which checks for a relation that has grown too big.
-Relations (in other words, tables and indexes) can be filtered with the
+=head2 B
+
+(symlinks: C, C,
+C, C, and
+C)
+
+The actions B and B check for a relation (table,
+index, materialized view), respectively an index that has grown too big, using
+the B function.
+
+The action B checks tables and materialized views using
+B, i.e. including relation forks and TOAST table.
+
+The action B checks tables and materialized views for
+the size of the attached indexes using B.
+
+The action B checks relations using
+B, i.e. including relation forks, indexes and TOAST
+table.
+
+Relations can be filtered with the
I<--include> and I<--exclude> options. See the L"BASIC FILTERING"> section
for more details. Relations can also be filtered by the user that owns them,
by using the I<--includeuser> and I<--excludeuser> options.
@@ -10136,6 +10156,13 @@ =head1 HISTORY
=item B Released ????
+ Change table_size to use pg_table_size(), i.e. to include the TOAST table
+ size in the numbers reported. Add new actions indexes_size and
+ total_relation_size, using the respective pg_indexes_size() and
+ pg_total_relation_size() functions. All size checks will now also check
+ materialized views where applicable.
+ (Christoph Berg)
+
Add Spanish message translations
(Luis Vazquez)
diff --git a/t/02_relation_size.t b/t/02_relation_size.t
index f13d914a..2825c9b9 100644
--- a/t/02_relation_size.t
+++ b/t/02_relation_size.t
@@ -6,7 +6,7 @@ use 5.006;
use strict;
use warnings;
use Data::Dumper;
-use Test::More tests => 23;
+use Test::More tests => 15 + 4 * 4;
use lib 't','.';
use CP_Testing;
@@ -97,11 +97,11 @@ $t = qq{$S includes indexes};
$dbh->do(qq{CREATE INDEX "${testtbl}_index" ON "$testtbl" (a)});
$dbh->commit;
like ($cp->run(qq{-w 1 --includeuser=$user --include=${testtbl}_index}),
- qr{$label WARNING.*largest relation is index "${testtbl}_index": \d+ kB}, $t);
+ qr{$label WARNING.*largest relation is index "\w+.${testtbl}_index": \d+ kB}, $t);
-#### Switch gears, and test the related functions "check_table_size" and "check_index_size".
+#### Switch gears, and test the other size actions
-for $S (qw(table_size index_size)) {
+for $S (qw(index_size table_size indexes_size total_relation_size)) {
$result = $cp->run($S, q{-w 1});
$label = "POSTGRES_\U$S";
@@ -123,9 +123,9 @@ for $S (qw(table_size index_size)) {
($S ne 'table_size'
? '_table'
: '_index');
- my $message = 'largest ' . ($S eq 'table_size'
- ? 'table'
- : 'index');
+ my $message = 'largest ' . ($S =~ /index/
+ ? 'index'
+ : 'table');
like ($cp->run($S, qq{-w 1 --includeuser=$user $include $exclude}),
qr|$label.*$message|, $t)
}
From 89fce2fc8c41c97560928ef2b22cd60a40320f5b Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 May 2016 21:09:43 +0200
Subject: [PATCH 047/272] txn_idle: if seconds are -0, use 0
Close: #75
---
check_postgres.pl | 1 +
1 file changed, 1 insertion(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 8704fc21..01fcdfcf 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -7961,6 +7961,7 @@ sub check_txn_idle {
## Extract the seconds to avoid typing out the hash each time
my $max = $maxr->{seconds};
+ $max = 0 if $max eq '-0';
## See if we have a minimum number of matches
my $base_count = $wcount || $ccount;
From b6800bdb2779ac22bf6c37169dad28d9e04c5a16 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 May 2016 21:33:01 +0200
Subject: [PATCH 048/272] Keep using pg_relation_size on 8.4 and earlier
pg_indexes_size doesn't exist either on 8.4, but that action is new, so
let's not care for now.
Also fix t/05_docs.t for the newly added actions.
---
check_postgres.pl | 9 ++++++---
t/05_docs.t | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 01fcdfcf..77aa39ae 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -6321,7 +6321,10 @@ sub check_relation_size {
$SQL .= $USERWHERECLAUSE;
}
- my $info = run_command($SQL, {emptyok => 1});
+ my $SQL8 = $SQL;
+ $SQL8 =~ s/pg_table_size/pg_relation_size/g; # 8.4 and earlier
+
+ my $info = run_command($SQL, {emptyok => 1, version => [ "<9.0 $SQL8" ] });
my $found = 0;
for $db (@{$info->{db}}) {
@@ -10157,8 +10160,8 @@ =head1 HISTORY
=item B Released ????
- Change table_size to use pg_table_size(), i.e. to include the TOAST table
- size in the numbers reported. Add new actions indexes_size and
+ Change table_size to use pg_table_size() on 9.0+, i.e. include the TOAST
+ table size in the numbers reported. Add new actions indexes_size and
total_relation_size, using the respective pg_indexes_size() and
pg_total_relation_size() functions. All size checks will now also check
materialized views where applicable.
diff --git a/t/05_docs.t b/t/05_docs.t
index 7c7541a3..7ef94999 100644
--- a/t/05_docs.t
+++ b/t/05_docs.t
@@ -38,6 +38,7 @@ for my $action (@actions) {
next if $action =~ /last_auto/;
my $match = $action;
+ $match = 'relation_size' if $match =~ /^(index|table|indexes|total_relation)_size/;
$match = 'pgb_pool' if $match =~ /pgb_pool/;
if ($slurp !~ /\n\s*sub check_$match/) {
From b91b2bd9eddda02a7a11ab79397d570ff3fa37f4 Mon Sep 17 00:00:00 2001
From: Martin von Oertzen
Date: Fri, 27 May 2016 14:19:39 +0200
Subject: [PATCH 049/272] removed 'o' modifier from regular expressions
http://stackoverflow.com/questions/550258/does-the-o-modifier-for-perl-regular-expressions-still-provide-any-benefit
---
check_postgres.pl | 56 +++++++++++++++++++++++------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 77aa39ae..1a4732a0 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1146,7 +1146,7 @@ package check_postgres;
RCLINE:
while (<$rc>) {
next if /^\s*#/;
- next unless /^\s*(\w+)\s*=\s*(.+?)\s*$/o;
+ next unless /^\s*(\w+)\s*=\s*(.+?)\s*$/;
my ($name,$value) = ($1,$2); ## no critic (ProhibitCaptureWithoutTest)
## Map alternate option spellings to preferred names
if ($name eq 'dbport' or $name eq 'p' or $name eq 'dbport1' or $name eq 'p1' or $name eq 'port1') {
@@ -1162,16 +1162,16 @@ package check_postgres;
$name = 'dbuser';
}
## Now for all the additional non-1 databases
- elsif ($name =~ /^dbport(\d+)$/o or $name eq /^p(\d+)$/o) {
+ elsif ($name =~ /^dbport(\d+)$/ or $name eq /^p(\d+)$/) {
$name = "port$1";
}
- elsif ($name =~ /^dbhost(\d+)$/o or $name eq /^H(\d+)$/o) {
+ elsif ($name =~ /^dbhost(\d+)$/ or $name eq /^H(\d+)$/) {
$name = "host$1";
}
- elsif ($name =~ /^db(\d)$/o) {
+ elsif ($name =~ /^db(\d)$/) {
$name = "dbname$1";
}
- elsif ($name =~ /^u(\d+)$/o) {
+ elsif ($name =~ /^u(\d+)$/) {
$name = "dbuser$1";
}
@@ -1257,24 +1257,24 @@ package check_postgres;
while (my $arg = pop @ARGV) {
## These must be of the form x=y
- if ($arg =~ /^\-?\-?(\w+)\s*=\s*(.+)/o) {
+ if ($arg =~ /^\-?\-?(\w+)\s*=\s*(.+)/) {
my ($name,$value) = (lc $1, $2);
- if ($name =~ /^(?:db)?port(\d+)$/o or $name =~ /^p(\d+)$/o) {
+ if ($name =~ /^(?:db)?port(\d+)$/ or $name =~ /^p(\d+)$/) {
push @{ $opt{port} } => $value;
}
- elsif ($name =~ /^(?:db)?host(\d+)$/o or $name =~ /^H(\d+)$/o) {
+ elsif ($name =~ /^(?:db)?host(\d+)$/ or $name =~ /^H(\d+)$/) {
push @{ $opt{host} } => $value;
}
- elsif ($name =~ /^db(?:name)?(\d+)$/o) {
+ elsif ($name =~ /^db(?:name)?(\d+)$/) {
push @{ $opt{dbname} } => $value;
}
- elsif ($name =~ /^dbuser(\d+)$/o or $name =~ /^u(\d+)/o) {
+ elsif ($name =~ /^dbuser(\d+)$/ or $name =~ /^u(\d+)/) {
push @{ $opt{dbuser} } => $value;
}
- elsif ($name =~ /^dbpass(\d+)$/o) {
+ elsif ($name =~ /^dbpass(\d+)$/) {
push @{ $opt{dbpass} } => $value;
}
- elsif ($name =~ /^dbservice(\d+)$/o) {
+ elsif ($name =~ /^dbservice(\d+)$/) {
push @{ $opt{dbservice} } => $value;
}
else {
@@ -1925,10 +1925,10 @@ sub finishup {
my $showdebug = 0;
if ($DEBUGOUTPUT) {
$showdebug = 1 if $DEBUGOUTPUT =~ /a/io
- or ($DEBUGOUTPUT =~ /c/io and $type eq 'c')
- or ($DEBUGOUTPUT =~ /w/io and $type eq 'w')
- or ($DEBUGOUTPUT =~ /o/io and $type eq 'o')
- or ($DEBUGOUTPUT =~ /u/io and $type eq 'u');
+ or ($DEBUGOUTPUT =~ /c/i and $type eq 'c')
+ or ($DEBUGOUTPUT =~ /w/i and $type eq 'w')
+ or ($DEBUGOUTPUT =~ /o/i and $type eq 'o')
+ or ($DEBUGOUTPUT =~ /u/i and $type eq 'u');
}
for (sort keys %$info) {
printf '%s %s%s ',
@@ -2683,7 +2683,7 @@ sub run_command {
$db->{slurp} = '' if ! defined $db->{slurp} or index($db->{slurp},'(')==0;
## Allow an empty query (no matching rows) if requested
- if ($arg->{emptyok} and $db->{slurp} =~ /^\s*$/o) {
+ if ($arg->{emptyok} and $db->{slurp} =~ /^\s*$/) {
$arg->{emptyok2} = 1;
}
## If we just want a version, grab it and redo
@@ -3048,7 +3048,7 @@ sub skip_item {
if (defined $opt{exclude}) {
$stat = 1;
for (@{$opt{exclude}}) {
- for my $ex (split /\s*,\s*/o => $_) {
+ for my $ex (split /\s*,\s*/ => $_) {
if ($ex =~ s/\.$//) {
if ($ex =~ s/^~//) {
($stat += 2 and last) if $schema =~ /$ex/;
@@ -3069,7 +3069,7 @@ sub skip_item {
if (defined $opt{include}) {
$stat += 4;
for (@{$opt{include}}) {
- for my $in (split /\s*,\s*/o => $_) {
+ for my $in (split /\s*,\s*/ => $_) {
if ($in =~ s/\.$//) {
if ($in =~ s/^~//) {
($stat += 8 and last) if $schema =~ /$in/;
@@ -3908,7 +3908,7 @@ sub check_bloat {
$db = $info->{db}[0];
- if ($db->{slurp} !~ /\w+/o) {
+ if ($db->{slurp} !~ /\w+/) {
add_ok msg('bloat-nomin') unless $MRTG;
return;
}
@@ -4307,7 +4307,7 @@ sub check_connection {
return;
}
- my $ver = ($db->{slurp}[0]{v} =~ /(\d+\.\d+\S+)/o) ? $1 : '';
+ my $ver = ($db->{slurp}[0]{v} =~ /(\d+\.\d+\S+)/) ? $1 : '';
$MRTG and do_mrtg({one => $ver ? 1 : 0});
@@ -6553,12 +6553,12 @@ sub check_same_schema {
for my $phrase (split /[\s,]+/ => $item) {
## Can be plain (e.g. nouser) or regex based exclusion, e.g. nouser=bob
- next if $phrase !~ /(\w+)=?\s*(.*)/o;
+ next if $phrase !~ /(\w+)=?\s*(.*)/;
my ($name,$regex) = (lc $1,$2||'');
## Names are standardized with regards to plurals and casing
- $name =~ s/([aeiou])s$/$1/o;
- $name =~ s/s$//o;
+ $name =~ s/([aeiou])s$/$1/;
+ $name =~ s/s$//;
if (! length $regex) {
$filter{"$name"} = 1;
@@ -7926,19 +7926,19 @@ sub check_txn_idle {
my $st = $r->{state} || '';
## Return unknown if we cannot see because we are a non-superuser
- if ($cq =~ /insufficient/o) {
+ if ($cq =~ /insufficient/) {
add_unknown msg('psa-nosuper');
return;
}
## Return unknown if stats_command_string / track_activities is off
- if ($st =~ /disabled/o or $cq =~ //) {
+ if ($st =~ /disabled/ or $cq =~ //) {
add_unknown msg('psa-disabled');
return;
}
## Detect other cases where pg_stat_activity is not fully populated
- if ($type ne 'qtime' and length $r->{xact_start} and $r->{xact_start} !~ /\d/o) {
+ if ($type ne 'qtime' and length $r->{xact_start} and $r->{xact_start} !~ /\d/) {
add_unknown msg('psa-noexact');
return;
}
@@ -8150,7 +8150,7 @@ sub check_version {
for $db (@{$info->{db}}) {
my $row = $db->{slurp}[0];
- if ($row->{version} !~ /((\d+\.\d+)(\w+|\.\d+))/o) {
+ if ($row->{version} !~ /((\d+\.\d+)(\w+|\.\d+))/) {
add_unknown msg('invalid-query', $row->{version});
next;
}
From b1d09afd1d89987b7aa6bab51bde4b264488527b Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 May 2016 22:18:32 +0200
Subject: [PATCH 050/272] Remove four more /o flags
---
check_postgres.pl | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 1a4732a0..77d53268 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1313,7 +1313,7 @@ package check_postgres;
if ($opt{get_method}) {
my $found = 0;
for my $meth (@get_methods) {
- if ($meth =~ /^$opt{get_method}/io) {
+ if ($meth =~ /^$opt{get_method}/i) {
@get_methods = ($meth);
$found = 1;
last;
@@ -1344,7 +1344,7 @@ package check_postgres;
if (!$OUTPUT) {
my $dir = getcwd;
- if ($dir =~ /(nagios|mrtg|simple|cacti)/io) {
+ if ($dir =~ /(nagios|mrtg|simple|cacti)/i) {
$OUTPUT = lc $1;
}
elsif ($opt{simple}) {
@@ -1361,7 +1361,7 @@ package check_postgres;
if ($OUTPUT =~ /\b(kb|mb|gb|tb|eb)\b/) {
$opt{transform} = uc $1;
}
-if ($OUTPUT =~ /(nagios|mrtg|simple|cacti)/io) {
+if ($OUTPUT =~ /(nagios|mrtg|simple|cacti)/i) {
$OUTPUT = lc $1;
}
## Check for a valid output setting
@@ -1924,7 +1924,7 @@ sub finishup {
## Are we showing DEBUG_INFO?
my $showdebug = 0;
if ($DEBUGOUTPUT) {
- $showdebug = 1 if $DEBUGOUTPUT =~ /a/io
+ $showdebug = 1 if $DEBUGOUTPUT =~ /a/i
or ($DEBUGOUTPUT =~ /c/i and $type eq 'c')
or ($DEBUGOUTPUT =~ /w/i and $type eq 'w')
or ($DEBUGOUTPUT =~ /o/i and $type eq 'o')
From 172c6c539896799ce597ea75250264d7f271b00f Mon Sep 17 00:00:00 2001
From: glynastill
Date: Thu, 16 Apr 2015 17:24:10 +0100
Subject: [PATCH 051/272] Fix "values are not the same" error in replicate_row
when repinfo value is a '0'
When check_replicate_row tested for valid values before starting the check, if the actual value returned was 0 it would evaluate to false, resulting in the error:
"Cannot test replication: values are not the same"
This is resolved by simply checking if the value is defined before assigning it's value a blank string instead.
---
check_postgres.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 77d53268..61a1d883 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -6442,11 +6442,11 @@ sub check_replicate_row {
if (!defined $sourcedb) {
ndie msg('rep-norow', "$table.$col");
}
- my $value1 = $info1->{db}[0]{slurp}[0]{c} || '';
+ my $value1 = (defined($info1->{db}[0]{slurp}[0]{c})?$info1->{db}[0]{slurp}[0]{c}:'');
my $numslaves = @{$info1->{db}} - 1;
for my $d ( @{$info1->{db}}[1 .. $numslaves] ) {
- my $value2 = $d->{slurp}[0]{c} || '';
+ my $value2 = (defined($d->{slurp}[0]{c})?$d->{slurp}[0]{c}:'');
if ($value1 ne $value2) {
ndie msg('rep-notsame');
}
From a3ea5253a6e657e8500d758b95e9cc181509a8fd Mon Sep 17 00:00:00 2001
From: glyn
Date: Thu, 10 Dec 2015 14:02:12 +0000
Subject: [PATCH 052/272] Add check_replication_slots check to check the delay
on any replication slots.
"Delay" is measured as size of transaction logs retained for the slot e.g:
check_postgres_replication_slots -db=TEST -H=192.168.0.106 -warning=32M -critical=64M
---
check_postgres.pl | 111 ++++++++++++++++++++++++++++++++++++
t/02_replication_slots.t | 119 +++++++++++++++++++++++++++++++++++++++
t/CP_Testing.pm | 7 +++
3 files changed, 237 insertions(+)
create mode 100644 t/02_replication_slots.t
diff --git a/check_postgres.pl b/check_postgres.pl
index 61a1d883..7bb2835a 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -187,6 +187,8 @@ package check_postgres;
'no-match-set' => q{No matching settings found due to exclusion/inclusion options},
'no-match-table' => q{No matching tables found due to exclusion/inclusion options},
'no-match-user' => q{No matching entries found due to user exclusion/inclusion options},
+ 'no-match-slot' => q{No matching replication slots found due to exclusion/inclusion options},
+ 'no-match-slotok' => q{No replication slots found},
'no-parse-psql' => q{Could not parse psql output!},
'no-time-hires' => q{Cannot find Time::HiRes, needed if 'showtime' is true},
'opt-output-invalid' => q{Invalid output: must be 'nagios' or 'mrtg' or 'simple' or 'cacti'},
@@ -259,6 +261,7 @@ package check_postgres;
'rep-timeout' => q{Row was not replicated. Timeout: $1},
'rep-unknown' => q{Replication check failed},
'rep-wrongvals' => q{Cannot test replication: values are not the right ones ('$1' not '$2' nor '$3')},
+ 'repslot-version' => q{Database must be version 9.4 or higher to check replication slots},
'runcommand-err' => q{Unknown error inside of the "run_command" function},
'runcommand-nodb' => q{No target databases could be found},
'runcommand-nodupe' => q{Could not dupe STDERR},
@@ -444,6 +447,8 @@ package check_postgres;
'no-match-set' => q{No se encuentran opciones de configuración coincidentes debido a las opciones de exclusión/inclusión},
'no-match-table' => q{No se encuentran tablas coincidentes debido a las opciones de exclusión/inclusión},
'no-match-user' => q{No se encuentran entradas coincidentes debido a las opciones de exclusión/inclusión},
+ 'no-match-slot' => q{No se encuentran ranuras de replicación coincidentes debido a las opciones de exclusión/inclusión},
+ 'no-match-slotok' => q{No se encuentran ranuras de replicación},
'no-parse-psql' => q{No se pudo interpretar la salida de psql!},
'no-time-hires' => q{No se encontró Time::HiRes, necesario si 'showtime' es verdadero},
'opt-output-invalid' => q{Formato de salida inválido: debe ser 'nagios' o 'mrtg' o 'simple' o 'cacti'},
@@ -515,6 +520,7 @@ package check_postgres;
'rep-timeout' => q{La fila no fue replicada. Timeout: $1},
'rep-unknown' => q{Chequeo de replicación fallido},
'rep-wrongvals' => q{No puedo verificar la replicación: los valores no son correctos ('$1' no '$2' ni '$3')},
+ 'repslot-version' => q{La base de datos debe ser version 9.4 o superior para ver las ranuras de replicación},
'runcommand-err' => q{Error desconocido en la función "run_command"},
'runcommand-nodb' => q{No se encontró ninguna base de datos buscada},
'runcommand-nodupe' => q{No fue posible duplicar STDERR},
@@ -700,6 +706,8 @@ package check_postgres;
'no-match-set' => q{Aucun paramètre trouvé à cause des options d'exclusion/inclusion},
'no-match-table' => q{Aucune table trouvée à cause des options d'exclusion/inclusion},
'no-match-user' => q{Aucune entrée trouvée à cause options d'exclusion/inclusion},
+ 'no-match-slot' => q{Aucune fentes de réplication trouvée à cause options d'exclusion/inclusion},
+ 'no-match-slotok' => q{Pas de fentes de réplication trouvé},
'no-parse-psql' => q{N'a pas pu analyser la sortie de psql !},
'no-time-hires' => q{N'a pas trouvé le module Time::HiRes, nécessaire quand « showtime » est activé},
'opt-output-invalid' => q{Sortie invalide : doit être 'nagios' ou 'mrtg' ou 'simple' ou 'cacti'},
@@ -771,6 +779,7 @@ package check_postgres;
'rep-timeout' => q{La ligne n'a pas été répliquée. Délai dépassé : $1},
'rep-unknown' => q{Échec du test de la réplication},
'rep-wrongvals' => q{Ne peut pas tester la réplication : les valeurs ne sont pas les bonnes (ni '$1' ni '$2' ni '$3')},
+ 'repslot-version' => q{Base de données doit être la version 9.4 ou ultérieure pour vérifier fentes de réplication},
'runcommand-err' => q{Erreur inconnue de la fonction « run_command »},
'runcommand-nodb' => q{Aucune base de données cible trouvée},
'runcommand-nodupe' => q{N'a pas pu dupliqué STDERR},
@@ -1438,6 +1447,7 @@ package check_postgres;
query_runtime => [0, 'Check how long a specific query takes to run.'],
query_time => [1, 'Checks the maximum running time of current queries.'],
replicate_row => [0, 'Verify a simple update gets replicated to another server.'],
+ replication_slots => [1, 'Check the replication delay for replication slots'],
same_schema => [0, 'Verify that two databases have the exact same tables, columns, etc.'],
sequence => [0, 'Checks remaining calls left in sequences.'],
settings_checksum => [0, 'Check that no settings have changed since the last check.'],
@@ -2013,6 +2023,7 @@ sub finishup {
fsm_pages => 'VERSION: 8.2 MAX: 8.3',
fsm_relations => 'VERSION: 8.2 MAX: 8.3',
hot_standby_delay => 'VERSION: 9.0',
+ replication_slots => 'VERSION: 9.4',
listener => 'MAX: 8.4',
);
if ($opt{test}) {
@@ -2208,6 +2219,9 @@ sub finishup {
## Check the replication delay in hot standby setup
check_hot_standby_delay() if $action eq 'hot_standby_delay';
+## Check the delay on replication slots. warning and critical are sizes
+check_replication_slots() if $action eq 'replication_slots';
+
## Check the maximum transaction age of all connections
check_txn_time() if $action eq 'txn_time';
@@ -5157,6 +5171,91 @@ sub check_hot_standby_delay {
} ## end of check_hot_standby_delay
+sub check_replication_slots {
+
+ ## Check the delay on one or more replication slots
+ ## Supports: Nagios, MRTG
+ ## mrtg reports the largest two delays
+ ## By default, checks all replication slots
+ ## Can check specific one(s) with include
+ ## Can ignore some with exclude
+ ## Warning and critical are bytes
+ ## Valid units: b, k, m, g, t, e
+ ## All above may be written as plural or with a trailing 'b'
+
+ my ($warning, $critical) = validate_range({type => 'size'});
+
+ $SQL = qq{
+ WITH slots AS (SELECT slot_name,
+ slot_type,
+ coalesce(restart_lsn, '0/0'::pg_lsn) AS slot_lsn,
+ coalesce(pg_xlog_location_diff(pg_current_xlog_location(), restart_lsn),0) AS delta,
+ active
+ FROM pg_replication_slots)
+ SELECT *, pg_size_pretty(delta) AS delta_pretty FROM slots;
+ };
+
+ if ($opt{perflimit}) {
+ $SQL .= " ORDER BY 1 DESC LIMIT $opt{perflimit}";
+ }
+
+ my $info = run_command($SQL, { regex => qr{\d+}, emptyok => 1, } );
+ my $found = 0;
+
+ for $db (@{$info->{db}}) {
+ my $max = -1;
+ $found = 1;
+ my %s;
+
+ for my $r (@{$db->{slurp}}) {
+ if (skip_item($r->{slot_name})) {
+ $max = -2 if ($max == -1 );
+ next;
+ }
+ if ($r->{delta} >= $max) {
+ $max = $r->{delta};
+ }
+ $s{$r->{slot_name}} = [$r->{delta},$r->{delta_pretty},$r->{slot_type},$r->{slot_lsn},$r->{active}];
+ }
+ if ($MRTG) {
+ do_mrtg({one => $max, msg => "SLOT: $db->{slot_name}"});
+ }
+ if ($max < 0) {
+ $stats{$db->{dbname}} = 0;
+ add_ok msg('no-match-slotok') if ($max == -1);
+ add_unknown msg('no-match-slot') if ($max == -2);
+ next;
+ }
+
+ my $msg = '';
+ for (sort {$s{$b}[0] <=> $s{$a}[0] or $a cmp $b } keys %s) {
+ $msg .= "$_: $s{$_}[1] ($s{$_}[2] $s{$_}[3] " . ($s{$_}[4] eq 't'?'active':'inactive') .") ";
+ $db->{perf} .= sprintf ' %s=%s;%s;%s',
+ perfname($_), $s{$_}[0], $warning, $critical;
+ }
+ if (length $critical and $max >= $critical) {
+ add_critical $msg;
+ }
+ elsif (length $warning and $max >= $warning) {
+ add_warning $msg;
+ }
+ else {
+ add_ok $msg;
+ }
+ }
+
+ ## If no results, probably a version problem
+ if (!$found and keys %unknown) {
+ (my $first) = values %unknown;
+ if ($first->[0][0] =~ /pg_replication_slots/) {
+ ndie msg('repslot-version');
+ }
+ }
+
+ return;
+
+} ## end of check_replication_slot_delay
+
sub check_last_analyze {
my $auto = shift || '';
@@ -9642,6 +9741,18 @@ =head2 B
The maximum time is set to 4 minutes 30 seconds: if no replication has taken place in that long
a time, an error is thrown.
+=head2 B
+
+(C) Check the quantity of WAL retained for any replication
+slots in the target database cluster. This is handy for monitoring environments where all WAL archiving
+and replication is taking place over replication slots.
+
+Warning and critical are total bytes retained for the slot. E.g:
+
+ check_postgres_replication_slots --port=5432 --host=yellow -warning=32M -critical=64M
+
+Specific named slots can be monitored using --include/--exclude
+
=head2 B
(C) Verifies that two or more databases are identical as far as their
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
new file mode 100644
index 00000000..1158a127
--- /dev/null
+++ b/t/02_replication_slots.t
@@ -0,0 +1,119 @@
+#!perl
+
+## Test the "replication_slots" action
+
+use 5.006;
+use strict;
+use warnings;
+use Data::Dumper;
+use Test::More tests => 20;
+use lib 't','.';
+use CP_Testing;
+
+use vars qw/$dbh $result $t $port $host $dbname/;
+
+my $cp = CP_Testing->new( {default_action => 'replication_slots'} );
+
+$dbh = $cp->test_database_handle();
+$dbh->{AutoCommit} = 1;
+$port = $cp->get_port();
+$host = $cp->get_host();
+$dbname = $cp->get_dbname;
+
+diag "Connected as $port:$host:$dbname\n";
+
+my $S = q{Action 'replication_slots'};
+my $label = 'POSTGRES_REPLICATION_SLOTS';
+
+$t = qq{$S self-identifies correctly};
+$result = $cp->run(q{-w 0});
+like ($result, qr{^$label}, $t);
+
+$t = qq{$S identifies host};
+like ($result, qr{host:$host}, $t);
+
+$t = qq{$S reports no replication slots};
+like ($result, qr{No replication slots found}, $t);
+
+$t = qq{$S accepts valid -w input};
+for my $arg (
+ '1 MB',
+ '1 GB',
+ ) {
+ like ($cp->run(qq{-w "$arg"}), qr{^$label}, "$t ($arg)");
+}
+
+$t = qq{$S rejects invalid -w input};
+for my $arg (
+ '-1 MB',
+ 'abc'
+ ) {
+ like ($cp->run(qq{-w "$arg"}), qr{^ERROR: Invalid size}, "$t ($arg)");
+}
+
+$dbh->do ("SELECT * FROM pg_create_physical_replication_slot('cp_testing_slot')");
+
+$t = qq{$S reports physical replication slots};
+$result = $cp->run(q{-w 0});
+like ($result, qr{cp_testing_slot.*physical}, $t);
+
+$t=qq{$S reports ok on physical replication slots when warning level is specified and not exceeded};
+$result = $cp->run(q{-w 1MB});
+like ($result, qr{^$label OK:}, $t);
+
+$t=qq{$S reports ok on physical replication slots when critical level is specified and not exceeded};
+$result = $cp->run(q{-c 1MB});
+like ($result, qr{^$label OK:}, $t);
+
+$dbh->do ("SELECT pg_drop_replication_slot('cp_testing_slot')");
+
+# To do more tests on physical slots we'd actually have to kick off some activity by performing a connection to them (.. use pg_receivexlog or similar??)
+
+$dbh->do ("SELECT * FROM pg_create_logical_replication_slot('cp_testing_slot', 'test_decoding')");
+
+$t = qq{$S reports logical replication slots};
+$result = $cp->run(q{-w 0});
+like ($result, qr{cp_testing_slot.*logical}, $t);
+
+$t=qq{$S reports ok on logical replication slots when warning level is specified and not exceeded};
+$result = $cp->run(q{-w 1MB});
+like ($result, qr{^$label OK:}, $t);
+
+$t=qq{$S reports ok on logical replication slots when critical level is specified and not exceeded};
+$result = $cp->run(q{-c 1MB});
+like ($result, qr{^$label OK:}, $t);
+
+$dbh->do ("CREATE TABLE cp_testing_table (a text); INSERT INTO cp_testing_table SELECT a || repeat('A',1024) FROM generate_series(1,1024) a; DROP TABLE cp_testing_table;");
+
+
+$t=qq{$S reports warning on logical replication slots when warning level is specified and is exceeded};
+$result = $cp->run(q{-w 1MB});
+like ($result, qr{^$label WARNING:}, $t);
+
+$t=qq{$S reports critical on logical replication slots when critical level is specified and is exceeded};
+$result = $cp->run(q{-c 1MB});
+like ($result, qr{^$label CRITICAL:}, $t);
+
+$t=qq{$S works when include has valid replication slot};
+$result = $cp->run(q{-w 1MB --include=cp_testing_slot});
+like ($result, qr{^$label WARNING:.*cp_testing_slot}, $t);
+
+$t=qq{$S works when include matches no replication slots};
+$result = $cp->run(q{-w 1MB --include=foobar});
+like ($result, qr{^$label UNKNOWN:.*No matching replication slots}, $t);
+
+$t=qq{$S returnes correct performance data with include};
+$result = $cp->run(q{-w 1MB --include=cp_testing_slot});
+like ($result, qr{ \| time=\d\.\d\ds cp_testing_slot=\d+}, $t);
+
+$t=qq{$S works when exclude excludes no replication slots};
+$result = $cp->run(q{-w 10MB --exclude=foobar});
+like ($result, qr{^$label OK:.*cp_testing_slot}, $t);
+
+$t=qq{$S works when exclude excludes all replication slots};
+$result = $cp->run(q{-w 10MB --exclude=cp_testing_slot});
+like ($result, qr{^$label UNKNOWN:.*No matching replication slots}, $t);
+
+$dbh->do ("SELECT pg_drop_replication_slot('cp_testing_slot')");
+
+exit;
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 95ed1e0f..7d4b6e9a 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -143,6 +143,13 @@ sub test_database_handle {
print $cfh qq{max_fsm_pages = 99999\n};
}
+ ## >= 9.4
+ if ($imaj > 9 or ($imaj==9 and $imin >= 4)) {
+ print $cfh qq{max_replication_slots = 2\n};
+ print $cfh qq{wal_level = logical\n};
+ print $cfh qq{max_wal_senders = 2\n};
+ }
+
print $cfh "\n";
close $cfh or die qq{Could not close "$cfile": $!\n};
From 90de7df4ecd99152f5c7ebd63d0bf81ddb2f43db Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Fri, 3 Jun 2016 16:53:16 +0200
Subject: [PATCH 053/272] Skip replication slot tests before 9.4
(Refers to #109)
---
t/02_replication_slots.t | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
index 1158a127..163d836c 100644
--- a/t/02_replication_slots.t
+++ b/t/02_replication_slots.t
@@ -25,6 +25,14 @@ diag "Connected as $port:$host:$dbname\n";
my $S = q{Action 'replication_slots'};
my $label = 'POSTGRES_REPLICATION_SLOTS';
+my $ver = $dbh->{pg_server_version};
+if ($ver < 90400) {
+ SKIP: {
+ skip 'replication slots not present before 9.4', 20;
+ }
+ exit 0;
+}
+
$t = qq{$S self-identifies correctly};
$result = $cp->run(q{-w 0});
like ($result, qr{^$label}, $t);
From 167503153c984b1e3065ff498002e1243689a3ee Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Sun, 5 Jun 2016 16:09:39 +0200
Subject: [PATCH 054/272] Add changelog entry for check_replication_slots
---
check_postgres.pl | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 7bb2835a..f46d2cfc 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -10278,6 +10278,10 @@ =head1 HISTORY
materialized views where applicable.
(Christoph Berg)
+ New action replication_slots checking if logical or physical replication
+ slots have accumulated too much data
+ (Glyn Astill)
+
Add Spanish message translations
(Luis Vazquez)
From 61dc82c8b4f527eb117604cba6c2cca88f777931 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Sun, 5 Jun 2016 18:17:49 +0200
Subject: [PATCH 055/272] Fix t/02_relation_size.t for 8.4 by skipping
indexes_size
---
t/02_relation_size.t | 3 +++
1 file changed, 3 insertions(+)
diff --git a/t/02_relation_size.t b/t/02_relation_size.t
index 2825c9b9..6ddeb8de 100644
--- a/t/02_relation_size.t
+++ b/t/02_relation_size.t
@@ -102,6 +102,8 @@ like ($cp->run(qq{-w 1 --includeuser=$user --include=${testtbl}_index}),
#### Switch gears, and test the other size actions
for $S (qw(index_size table_size indexes_size total_relation_size)) {
+SKIP: {
+ skip "$S not supported before 9.0", 4 if ($S eq 'indexes_size' and $ver < 90000);
$result = $cp->run($S, q{-w 1});
$label = "POSTGRES_\U$S";
@@ -129,5 +131,6 @@ for $S (qw(index_size table_size indexes_size total_relation_size)) {
like ($cp->run($S, qq{-w 1 --includeuser=$user $include $exclude}),
qr|$label.*$message|, $t)
}
+}
exit;
From 755994d839a0d05ade7eeb8fe984eb36bd78e565 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Sun, 5 Jun 2016 14:32:09 +0200
Subject: [PATCH 056/272] Speed up testing by disabling fsync
---
t/CP_Testing.pm | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 7d4b6e9a..248c9d3e 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -92,6 +92,17 @@ sub test_database_handle {
: $ENV{PGBINDIR} ? "$ENV{PGBINDIR}/initdb"
: 'initdb';
+ ## Grab the version for finicky items
+ if (qx{$initdb --version} !~ /(\d+)\.(\d+)/) {
+ die qq{Could not determine the version of initdb in use!\n};
+ }
+ my ($imaj,$imin) = ($1,$2);
+
+ # Speed up testing on 9.3+
+ if ($imaj > 9 or ($imaj==9 and $imin >= 3)) {
+ $initdb = "$initdb --nosync";
+ }
+
$com = qq{LC_ALL=en LANG=C $initdb --locale=C -E UTF8 -D "$datadir" 2>&1};
eval {
$DEBUG and warn qq{About to run: $com\n};
@@ -108,12 +119,7 @@ sub test_database_handle {
print $cfh qq{port = 5432\n};
print $cfh qq{listen_addresses = ''\n};
print $cfh qq{max_connections = 10\n};
-
- ## Grab the version for finicky items
- if (qx{$initdb --version} !~ /(\d+)\.(\d+)/) {
- die qq{Could not determine the version of initdb in use!\n};
- }
- my ($imaj,$imin) = ($1,$2);
+ print $cfh qq{fsync = off\n};
## <= 8.0
if ($imaj < 8 or ($imaj==8 and $imin <= 1)) {
From a309c46983b2d695673ec2365badb2b01aa2da22 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Sun, 5 Jun 2016 16:06:20 +0200
Subject: [PATCH 057/272] Minimize number of errors in the server log during
testing
---
t/CP_Testing.pm | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 248c9d3e..d9de296f 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -349,11 +349,14 @@ sub test_database_handle {
$dbh->do("CREATE USER $user2");
}
}
- $dbh->do('CREATE DATABASE beedeebeedee');
- $dbh->do('CREATE DATABASE ardala');
- $dbh->do('CREATE LANGUAGE plpgsql');
- $dbh->do('CREATE LANGUAGE plperlu');
- $dbh->do("CREATE SCHEMA $fakeschema");
+
+ my $databases = $dbh->selectall_hashref('SELECT datname FROM pg_database', 'datname');
+ $dbh->do('CREATE DATABASE beedeebeedee') unless ($databases->{beedeebeedee});
+ $dbh->do('CREATE DATABASE ardala') unless ($databases->{ardala});
+ my $languages = $dbh->selectall_hashref('SELECT lanname FROM pg_language', 'lanname');
+ $dbh->do('CREATE LANGUAGE plpgsql') unless ($languages->{plpgsql});
+ my $schemas = $dbh->selectall_hashref('SELECT nspname FROM pg_namespace', 'nspname');
+ $dbh->do("CREATE SCHEMA $fakeschema") unless ($schemas->{$fakeschema});
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
@@ -388,7 +391,7 @@ sub test_database_handle {
sub recreate_database {
- ## Given a database handle, comepletely recreate the current database
+ ## Given a database handle, completely recreate the current database
my ($self,$dbh) = @_;
@@ -835,6 +838,12 @@ sub database_sleep {
my $ver = $dbh->{pg_server_version};
if ($ver < 80200) {
+ $dbh->{AutoCommit} = 1;
+ $dbh->{RaiseError} = 0;
+ $dbh->do('CREATE LANGUAGE plperlu');
+ $dbh->{AutoCommit} = 0;
+ $dbh->{RaiseError} = 1;
+
$SQL = q{CREATE OR REPLACE FUNCTION pg_sleep(float) RETURNS VOID LANGUAGE plperlu AS 'select(undef,undef,undef,shift)'};
$dbh->do($SQL);
$dbh->commit();
From 33b180d516172087a6caf2a654cafcda1220a4ad Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Fri, 3 Jun 2016 20:02:03 +0200
Subject: [PATCH 058/272] Add travis CI integration script to run the
check_postgres testsuite on travis-ci.com
---
.travis.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 .travis.yml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..051d535f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,45 @@
+# run the check_postgres testsuite on travis-ci.com
+---
+# versions to run on
+env:
+ - PGVERSION=8.4
+ - PGVERSION=9.0
+ - PGVERSION=9.1
+ - PGVERSION=9.2
+ - PGVERSION=9.3
+ - PGVERSION=9.4
+ - PGVERSION=9.5
+ - PGVERSION=9.6
+
+# we don't set "language: perl" here because that doesn't use the system perl
+
+before_install:
+ # apt.postgresql.org is already configured, we just need to add 9.6
+ - |
+ if [ "$PGVERSION" = "9.6" ]; then
+ # update pgdg-source.list
+ sudo sed -i -e 's/main/main 9.6/' /etc/apt/sources.list.d/pgdg*.list
+ fi
+ - sudo apt-get -qq update
+
+install:
+ - sudo apt-get install libdbd-pg-perl
+ # install PostgreSQL $PGVERSION if not there yet
+ - |
+ if [ ! -x /usr/lib/postgresql/$PGVERSION/bin/postgres ]; then
+ sudo apt-get install postgresql-common
+ sudo /etc/init.d/postgresql stop # travis wants only one version running
+ sudo apt-get install postgresql-contrib-$PGVERSION
+ fi
+ - sudo /etc/init.d/postgresql stop
+ - pg_lsclusters
+ - dpkg -l postgresql\* | cat
+ - printenv | sort
+
+script:
+ - rm -rf test_database_check_postgres*
+ - perl Makefile.PL
+ - PGBINDIR=/usr/lib/postgresql/$PGVERSION/bin make test
+
+after_script:
+ - tail -n 200 test_database_check_postgres*/pg.log
From 1a25cff190c0ec0628a25bca42b6a18e71051c0d Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Mon, 6 Jun 2016 19:03:36 +0200
Subject: [PATCH 059/272] Replace $dbh->tables() with selectall_arrayref()
$dbh->tables() seems to be throwing errors in travis. Replace by
a standard catalog query.
t/02_commitratio.t ......... DBD::Pg::db tables failed: no statement executing at t/CP_Testing.pm line 825.
Looks like your test exited with 255 before it could output anything.
---
t/CP_Testing.pm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index d9de296f..0ed72874 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -821,9 +821,9 @@ sub drop_all_tables {
my $self = shift;
my $dbh = $self->{dbh} || die;
$dbh->{Warn} = 0;
- my @info = $dbh->tables('','public','','TABLE');
- for my $tab (@info) {
- $dbh->do("DROP TABLE $tab CASCADE");
+ my $tables = $dbh->selectall_arrayref("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
+ for my $tab (@$tables) {
+ $dbh->do("DROP TABLE $tab->[0] CASCADE");
}
$dbh->{Warn} = 1;
$dbh->commit();
From 5b3499e20c4706ff3e8a2caa92cf58c21c20832f Mon Sep 17 00:00:00 2001
From: glynastill
Date: Thu, 16 Apr 2015 13:25:10 +0100
Subject: [PATCH 060/272] Fix same_schema to ignore some non-logical schema
based values:
operators - Use text descriptions for result type and operands; ignore related oids
triggers - Include table name in key to prevent false positive when another table has a trigger with the same name. Use textual trigger definition; ignore tgqual represe
functions - Use text function definition; ignore oid based types and defaults.
constraints - Include table name in key to prevent false positive when another table has a constraint with the same name. Use text constraint definition; ignore oid based values.
sequence - Ignore last_value; I'm confused as to why we'd want to know this on a schema check. But if required could be added back in with an optional filter instead.
indexes - Ignore reltablespace oid; we check the tablespace name anyway. Ignore indkey attnum which can differ when tables have been altered differently but are otherwis
---
check_postgres.pl | 49 +++++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 16 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index f46d2cfc..92a35e88 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1066,25 +1066,34 @@ package check_postgres;
},
operator => {
SQL => q{
-SELECT o.*, o.oid, nspname||'.'||o.oprname AS name, quote_ident(o.oprname) AS safename,
- usename AS owner, nspname AS schema,
+SELECT o.*, o.oid, n.nspname||'.'||o.oprname AS name, quote_ident(o.oprname) AS safename,
+ usename AS owner, n.nspname AS schema,
t1.typname AS resultname,
- t2.typname AS leftname, t3.typname AS rightname
+ t2.typname AS leftname, t3.typname AS rightname,
+ t4.typname AS resultname,
+ nneg.nspname||'.'||neg.oprname AS negname,
+ ncom.nspname||'.'||com.oprname AS comname
FROM pg_operator o
JOIN pg_user u ON (u.usesysid = o.oprowner)
JOIN pg_namespace n ON (n.oid = o.oprnamespace)
JOIN pg_proc p1 ON (p1.oid = o.oprcode)
JOIN pg_type t1 ON (t1.oid = o.oprresult)
LEFT JOIN pg_type t2 ON (t2.oid = o.oprleft)
-LEFT JOIN pg_type t3 ON (t3.oid = o.oprright)},
+LEFT JOIN pg_type t3 ON (t3.oid = o.oprright)
+LEFT JOIN pg_type t4 ON (t4.oid = o.oprresult)
+LEFT JOIN pg_operator neg ON (o.oprnegate = neg.oid)
+LEFT JOIN pg_namespace nneg ON (nneg.oid = neg.oprnamespace)
+LEFT JOIN pg_operator com ON (o.oprcom = com.oid)
+LEFT JOIN pg_namespace ncom ON (ncom.oid = com.oprnamespace)},
exclude => 'system',
},
trigger => {
SQL => q{
-SELECT t.*, n1.nspname||'.'||t.tgname AS name, quote_ident(t.tgname) AS safename, quote_ident(usename) AS owner,
+SELECT t.*, n1.nspname||'.'||c1.relname||'.'||t.tgname AS name, quote_ident(t.tgname) AS safename, quote_ident(usename) AS owner,
n1.nspname AS tschema, c1.relname AS tname,
n2.nspname AS cschema, c2.relname AS cname,
- n3.nspname AS procschema, p.proname AS procname
+ n3.nspname AS procschema, p.proname AS procname,
+ pg_get_triggerdef(t.oid) AS triggerdef
FROM pg_trigger t
JOIN pg_class c1 ON (c1.oid = t.tgrelid)
JOIN pg_user u ON (u.usesysid = c1.relowner)
@@ -1099,7 +1108,8 @@ package check_postgres;
SQL => q{
SELECT p.*, p.oid, nspname||'.'||p.proname AS name, quote_ident(p.proname) AS safename,
md5(prosrc) AS source_checksum,
- usename AS owner, nspname AS schema
+ usename AS owner, nspname AS schema,
+ pg_get_function_arguments(p.oid) AS function_arguments
FROM pg_proc p
JOIN pg_user u ON (u.usesysid = p.proowner)
JOIN pg_namespace n ON (n.oid = p.pronamespace)},
@@ -1107,9 +1117,11 @@ package check_postgres;
},
constraint => {
SQL => q{
-SELECT c.*, c.oid, n.nspname||'.'||c.conname AS name, quote_ident(c.conname) AS safename,
- n.nspname AS schema, relname AS tname
+SELECT c.*, c.oid, n.nspname||'.'||c1.relname||'.'||c.conname AS name, quote_ident(c.conname) AS safename,
+ n.nspname AS schema, r.relname AS tname,
+ pg_get_constraintdef(c.oid) AS constraintdef
FROM pg_constraint c
+JOIN pg_class c1 ON (c1.oid = c.conrelid)
JOIN pg_namespace n ON (n.oid = c.connamespace)
JOIN pg_class r ON (r.oid = c.conrelid)
JOIN pg_namespace n2 ON (n2.oid = r.relnamespace)},
@@ -6728,19 +6740,24 @@ sub check_same_schema {
my @catalog_items = (
[user => 'usesysid', 'useconfig' ],
[language => 'laninline,lanplcallfoid,lanvalidator', '' ],
- [operator => '', '' ],
+ [operator => 'oprleft,oprright,oprresult,oprnegate,
+ oprcom', '' ],
[type => '', '' ],
[schema => '', '' ],
- [function => 'source_checksum,prolang,prorettype', '' ],
+ [function => 'source_checksum,prolang,prorettype,
+ proargtypes,proallargtypes,provariadic,
+ proargdefaults', '' ],
[table => 'reltype,relfrozenxid,relminmxid,relpages,
reltuples,relnatts,relallvisible', '' ],
[view => 'reltype', '' ],
- [sequence => 'reltype,log_cnt,relnatts,is_called', '' ],
+ [sequence => 'reltype,log_cnt,relnatts,is_called,
+ last_value', '' ],
[index => 'relpages,reltuples,indpred,indclass,
- indexprs,indcheckxmin', '' ],
- [trigger => '', '' ],
- [constraint => 'conbin', '' ],
- [column => 'atttypid,attnum,attbyval', '' ],
+ indexprs,indcheckxmin,reltablespace,
+ indkey', '' ],
+ [trigger => 'tgqual,tgconstraint', '' ],
+ [constraint => 'conbin,conindid,conkey,confkey', '' ],
+ [column => 'atttypid,attnum,attbyval,attndims', '' ],
);
## Where we store all the information, per-database
From c1e1aeb66abc6957ce5f5071b9da10022bc2ddc2 Mon Sep 17 00:00:00 2001
From: glynastill
Date: Wed, 17 Jun 2015 11:33:12 +0100
Subject: [PATCH 061/272] Modify checks that return or rely on a user name to
reference pg_roles rather than pg_user.
This resolves issues where objects owned by a group role are missing in various checks (check_same_schema, check_commitratio, check_hitratio), or detail is missing (check_database_size), or results not filtered as intended (check_last_vacuum_analyze, check_relation_size).
Conflicts:
check_postgres.pl
---
check_postgres.pl | 56 +++++++++++++++++++++++------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 92a35e88..2ac925f7 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -988,17 +988,17 @@ package check_postgres;
schema => {
SQL => q{
-SELECT n.oid, quote_ident(nspname) AS name, quote_ident(usename) AS owner, nspacl
+SELECT n.oid, quote_ident(nspname) AS name, quote_ident(rolname) AS owner, nspacl
FROM pg_namespace n
-JOIN pg_user u ON (u.usesysid = n.nspowner)},
+JOIN pg_roles r ON (r.oid = n.nspowner)},
deletecols => [ ],
exclude => 'temp_schemas',
},
language => {
SQL => q{
-SELECT l.*, lanname AS name, quote_ident(usename) AS owner
+SELECT l.*, lanname AS name, quote_ident(rolname) AS owner
FROM pg_language l
-JOIN pg_user u ON (u.usesysid = l.lanowner)},
+JOIN pg_roles r ON (r.oid = l.lanowner)},
SQL2 => q{
SELECT l.*, lanname AS name
FROM pg_language l
@@ -1006,32 +1006,32 @@ package check_postgres;
},
type => {
SQL => q{
-SELECT t.oid AS oid, t.*, quote_ident(usename) AS owner, quote_ident(nspname) AS schema,
+SELECT t.oid AS oid, t.*, quote_ident(rolname) AS owner, quote_ident(nspname) AS schema,
nspname||'.'||typname AS name
FROM pg_type t
-JOIN pg_user u ON (u.usesysid = t.typowner)
+JOIN pg_roles r ON (r.oid = t.typowner)
JOIN pg_namespace n ON (n.oid = t.typnamespace)
WHERE t.typtype NOT IN ('b','c')},
exclude => 'system',
},
sequence => {
SQL => q{
-SELECT c.*, nspname||'.'||relname AS name, quote_ident(usename) AS owner,
+SELECT c.*, nspname||'.'||relname AS name, quote_ident(rolname) AS owner,
(quote_ident(nspname)||'.'||quote_ident(relname)) AS safename,
quote_ident(nspname) AS schema
FROM pg_class c
-JOIN pg_user u ON (u.usesysid = c.relowner)
+JOIN pg_roles r ON (r.oid = c.relowner)
JOIN pg_namespace n ON (n.oid = c.relnamespace)
WHERE c.relkind = 'S'},
innerSQL => 'SELECT * FROM ROWSAFENAME',
},
view => {
SQL => q{
-SELECT c.*, nspname||'.'||relname AS name, quote_ident(usename) AS owner,
+SELECT c.*, nspname||'.'||relname AS name, quote_ident(rolname) AS owner,
quote_ident(relname) AS safename, quote_ident(nspname) AS schema,
TRIM(pg_get_viewdef(c.oid, TRUE)) AS viewdef, spcname AS tablespace
FROM pg_class c
-JOIN pg_user u ON (u.usesysid = c.relowner)
+JOIN pg_roles r ON (r.oid = c.relowner)
JOIN pg_namespace n ON (n.oid = c.relnamespace)
LEFT JOIN pg_tablespace s ON (s.oid = c.reltablespace)
WHERE c.relkind = 'v'},
@@ -1039,11 +1039,11 @@ package check_postgres;
},
table => {
SQL => q{
-SELECT c.*, nspname||'.'||relname AS name, quote_ident(usename) AS owner,
+SELECT c.*, nspname||'.'||relname AS name, quote_ident(rolname) AS owner,
quote_ident(relname) AS safename, quote_ident(nspname) AS schema,
spcname AS tablespace
FROM pg_class c
-JOIN pg_user u ON (u.usesysid = c.relowner)
+JOIN pg_roles r ON (r.oid = c.relowner)
JOIN pg_namespace n ON (n.oid = c.relnamespace)
LEFT JOIN pg_tablespace s ON (s.oid = c.reltablespace)
WHERE c.relkind = 'r'},
@@ -1051,12 +1051,12 @@ package check_postgres;
},
index => {
SQL => q{
-SELECT c.*, i.*, nspname||'.'||relname AS name, quote_ident(usename) AS owner,
+SELECT c.*, i.*, nspname||'.'||relname AS name, quote_ident(rolname) AS owner,
quote_ident(relname) AS safename, quote_ident(nspname) AS schema,
spcname AS tablespace, amname,
pg_get_indexdef(c.oid) AS indexdef
FROM pg_class c
-JOIN pg_user u ON (u.usesysid = c.relowner)
+JOIN pg_roles r ON (r.oid = c.relowner)
JOIN pg_namespace n ON (n.oid = c.relnamespace)
JOIN pg_index i ON (c.oid = i.indexrelid)
LEFT JOIN pg_tablespace s ON (s.oid = c.reltablespace)
@@ -1067,14 +1067,14 @@ package check_postgres;
operator => {
SQL => q{
SELECT o.*, o.oid, n.nspname||'.'||o.oprname AS name, quote_ident(o.oprname) AS safename,
- usename AS owner, n.nspname AS schema,
+ rolname AS owner, n.nspname AS schema,
t1.typname AS resultname,
t2.typname AS leftname, t3.typname AS rightname,
t4.typname AS resultname,
nneg.nspname||'.'||neg.oprname AS negname,
ncom.nspname||'.'||com.oprname AS comname
FROM pg_operator o
-JOIN pg_user u ON (u.usesysid = o.oprowner)
+JOIN pg_roles r ON (r.oid = o.oprowner)
JOIN pg_namespace n ON (n.oid = o.oprnamespace)
JOIN pg_proc p1 ON (p1.oid = o.oprcode)
JOIN pg_type t1 ON (t1.oid = o.oprresult)
@@ -1089,14 +1089,14 @@ package check_postgres;
},
trigger => {
SQL => q{
-SELECT t.*, n1.nspname||'.'||c1.relname||'.'||t.tgname AS name, quote_ident(t.tgname) AS safename, quote_ident(usename) AS owner,
+SELECT t.*, n1.nspname||'.'||c1.relname||'.'||t.tgname AS name, quote_ident(t.tgname) AS safename, quote_ident(rolname) AS owner,
n1.nspname AS tschema, c1.relname AS tname,
n2.nspname AS cschema, c2.relname AS cname,
n3.nspname AS procschema, p.proname AS procname,
pg_get_triggerdef(t.oid) AS triggerdef
FROM pg_trigger t
JOIN pg_class c1 ON (c1.oid = t.tgrelid)
-JOIN pg_user u ON (u.usesysid = c1.relowner)
+JOIN pg_roles r ON (r.oid = c1.relowner)
JOIN pg_namespace n1 ON (n1.oid = c1.relnamespace)
JOIN pg_proc p ON (p.oid = t.tgfoid)
JOIN pg_namespace n3 ON (n3.oid = p.pronamespace)
@@ -1108,10 +1108,10 @@ package check_postgres;
SQL => q{
SELECT p.*, p.oid, nspname||'.'||p.proname AS name, quote_ident(p.proname) AS safename,
md5(prosrc) AS source_checksum,
- usename AS owner, nspname AS schema,
+ rolname AS owner, nspname AS schema,
pg_get_function_arguments(p.oid) AS function_arguments
FROM pg_proc p
-JOIN pg_user u ON (u.usesysid = p.proowner)
+JOIN pg_roles r ON (r.oid = p.proowner)
JOIN pg_namespace n ON (n.oid = p.pronamespace)},
exclude => 'system',
},
@@ -4240,10 +4240,10 @@ sub check_commitratio {
SELECT
round(100.*sd.xact_commit/(sd.xact_commit+sd.xact_rollback), 2) AS dcommitratio,
d.datname,
- u.usename
+ r.rolname AS usename
FROM pg_stat_database sd
JOIN pg_database d ON (d.oid=sd.datid)
-JOIN pg_user u ON (u.usesysid=d.datdba)
+JOIN pg_roles r ON (r.oid=d.datdba)
WHERE sd.xact_commit+sd.xact_rollback<>0
$USERWHERECLAUSE
};
@@ -4455,9 +4455,9 @@ sub check_database_size {
SELECT pg_database_size(d.oid) AS dsize,
pg_size_pretty(pg_database_size(d.oid)) AS pdsize,
datname,
- usename
+ r.rolname AS usename
FROM pg_database d
-LEFT JOIN pg_user u ON (u.usesysid=d.datdba)$USERWHERECLAUSE
+LEFT JOIN pg_roles r ON (r.oid=d.datdba)$USERWHERECLAUSE
};
if ($opt{perflimit}) {
$SQL .= " ORDER BY 1 DESC LIMIT $opt{perflimit}";
@@ -4964,10 +4964,10 @@ sub check_hitratio {
SELECT
round(100.*sd.blks_hit/(sd.blks_read+sd.blks_hit), 2) AS dhitratio,
d.datname,
- u.usename
+ r.rolname AS usename
FROM pg_stat_database sd
JOIN pg_database d ON (d.oid=sd.datid)
-JOIN pg_user u ON (u.usesysid=d.datdba)
+JOIN pg_roles r ON (r.oid=d.datdba)
WHERE sd.blks_read+sd.blks_hit<>0
$USERWHERECLAUSE
};
@@ -5327,7 +5327,7 @@ sub check_last_vacuum_analyze {
}
if ($USERWHERECLAUSE) {
- $SQL =~ s/ WHERE/, pg_user u WHERE u.usesysid=c.relowner$USERWHERECLAUSE AND/;
+ $SQL =~ s/ WHERE/, pg_roles r WHERE r.oid=c.relowner$USERWHERECLAUSE AND/;
}
my $info = run_command($SQL, { regex => qr{\w}, emptyok => 1 } );
@@ -6428,7 +6428,7 @@ sub check_relation_size {
}
if ($USERWHERECLAUSE) {
- $SQL =~ s/WHERE/JOIN pg_user u ON (c.relowner = u.usesysid) WHERE/;
+ $SQL =~ s/WHERE/JOIN pg_roles r ON (c.relowner = r.oid) WHERE/;
$SQL .= $USERWHERECLAUSE;
}
From 3e5f5f7fbc5b56695e316ed42bec65e7d15715d5 Mon Sep 17 00:00:00 2001
From: glynastill
Date: Tue, 23 Jun 2015 14:45:25 +0100
Subject: [PATCH 062/272] Fix USERWHERECLAUSE broken when changing pg_user
references to pg_role
---
check_postgres.pl | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 2ac925f7..c726d10a 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -981,7 +981,7 @@ package check_postgres;
user => {
SQL => q{
-SELECT *, usename AS name, quote_ident(usename) AS safeusename
+SELECT *, usename AS name, quote_ident(usename) AS saferolname
FROM pg_user},
deletecols => [ qw{ passwd } ],
},
@@ -2120,10 +2120,10 @@ sub finishup {
my $safename;
if (1 == keys %userlist) {
($safename = each %userlist) =~ s/'/''/g;
- $USERWHERECLAUSE = " AND usename = '$safename'";
+ $USERWHERECLAUSE = " AND rolname = '$safename'";
}
else {
- $USERWHERECLAUSE = ' AND usename IN (';
+ $USERWHERECLAUSE = ' AND rolname IN (';
for my $user (sort keys %userlist) {
($safename = $user) =~ s/'/''/g;
$USERWHERECLAUSE .= "'$safename',";
@@ -2142,10 +2142,10 @@ sub finishup {
my $safename;
if (1 == keys %userlist) {
($safename = each %userlist) =~ s/'/''/g;
- $USERWHERECLAUSE = " AND usename <> '$safename'";
+ $USERWHERECLAUSE = " AND rolname <> '$safename'";
}
else {
- $USERWHERECLAUSE = ' AND usename NOT IN (';
+ $USERWHERECLAUSE = ' AND rolname NOT IN (';
for my $user (sort keys %userlist) {
($safename = $user) =~ s/'/''/g;
$USERWHERECLAUSE .= "'$safename',";
@@ -4240,7 +4240,7 @@ sub check_commitratio {
SELECT
round(100.*sd.xact_commit/(sd.xact_commit+sd.xact_rollback), 2) AS dcommitratio,
d.datname,
- r.rolname AS usename
+ r.rolname AS rolname
FROM pg_stat_database sd
JOIN pg_database d ON (d.oid=sd.datid)
JOIN pg_roles r ON (r.oid=d.datdba)
@@ -4455,7 +4455,7 @@ sub check_database_size {
SELECT pg_database_size(d.oid) AS dsize,
pg_size_pretty(pg_database_size(d.oid)) AS pdsize,
datname,
- r.rolname AS usename
+ r.rolname AS rolname
FROM pg_database d
LEFT JOIN pg_roles r ON (r.oid=d.datdba)$USERWHERECLAUSE
};
@@ -4964,7 +4964,7 @@ sub check_hitratio {
SELECT
round(100.*sd.blks_hit/(sd.blks_read+sd.blks_hit), 2) AS dhitratio,
d.datname,
- r.rolname AS usename
+ r.rolname AS rolname
FROM pg_stat_database sd
JOIN pg_database d ON (d.oid=sd.datid)
JOIN pg_roles r ON (r.oid=d.datdba)
@@ -6825,7 +6825,7 @@ sub check_same_schema {
## Map the oid back to the user, for ease later on
for my $row (values %{ $dbinfo->{user} }) {
- $dbinfo->{useroid}{$row->{usesysid}} = $row->{usename};
+ $dbinfo->{useroid}{$row->{usesysid}} = $row->{rolname};
}
$thing{$x} = $dbinfo;
@@ -7991,6 +7991,8 @@ sub check_txn_idle {
qq{COALESCE(ROUND(EXTRACT(epoch FROM now()-$start)),0) AS seconds }.
qq{FROM pg_stat_activity WHERE ($clause)$USERWHERECLAUSE }.
q{ORDER BY xact_start, query_start, procpid DESC};
+ # Handle usename /rolname differences
+ $SQL =~ s/rolname/usename/;
## Craft an alternate version for old servers that do not have the xact_start column:
($SQL2 = $SQL) =~ s/xact_start/query_start AS xact_start/;
$SQL2 =~ s/BY xact_start,/BY/;
@@ -8001,6 +8003,9 @@ sub check_txn_idle {
qq{COALESCE(ROUND(EXTRACT(epoch FROM now()-$start)),0) AS seconds }.
qq{FROM pg_stat_activity WHERE ($clause)$USERWHERECLAUSE }.
q{ORDER BY query_start, procpid DESC};
+ # Handle usename /rolname differences
+ $SQL =~ s/rolname/usename/;
+ $SQL2 =~ s/rolname/usename/;
}
## Craft an alternate version for new servers which do not have procpid and current_query is split
@@ -8095,7 +8100,7 @@ sub check_txn_idle {
$whodunit = sprintf q{%s:%s %s:%s %s:%s%s%s %s:%s},
msg('PID'), $maxr->{pid},
msg('database'), $maxr->{datname},
- msg('username'), $maxr->{usename},
+ msg('username'), $maxr->{rolname},
$maxr->{client_addr} eq '' ? '' : (sprintf ' %s:%s', msg('address'), $maxr->{client_addr}),
($maxr->{client_port} eq '' or $maxr->{client_port} < 1)
? '' : (sprintf ' %s:%s', msg('port'), $maxr->{client_port}),
From dcb6455e00ca030241bdd35a260ee23ca9e615b8 Mon Sep 17 00:00:00 2001
From: glynastill
Date: Thu, 13 Aug 2015 17:23:43 +0100
Subject: [PATCH 063/272] Fix same schema to treat pg_constraint.confmatchtype
= 'u' = 's'
This relates to a change in the character representing a simple match
on a foreign key stored in the confmatchtype field changing from 'u'
to 's' between postgresql 9.2 and 9.3. Ref:
http://www.postgresql.org/docs/9.2/static/catalog-pg-constraint.html
http://www.postgresql.org/docs/9.3/static/catalog-pg-constraint.html
---
check_postgres.pl | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index c726d10a..e2950155 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1119,7 +1119,7 @@ package check_postgres;
SQL => q{
SELECT c.*, c.oid, n.nspname||'.'||c1.relname||'.'||c.conname AS name, quote_ident(c.conname) AS safename,
n.nspname AS schema, r.relname AS tname,
- pg_get_constraintdef(c.oid) AS constraintdef
+ pg_get_constraintdef(c.oid) AS constraintdef, translate(c.confmatchtype,'u','s') AS confmatchtype_compat
FROM pg_constraint c
JOIN pg_class c1 ON (c1.oid = c.conrelid)
JOIN pg_namespace n ON (n.oid = c.connamespace)
@@ -6756,7 +6756,8 @@ sub check_same_schema {
indexprs,indcheckxmin,reltablespace,
indkey', '' ],
[trigger => 'tgqual,tgconstraint', '' ],
- [constraint => 'conbin,conindid,conkey,confkey', '' ],
+ [constraint => 'conbin,conindid,conkey,confkey
+ confmatchtype', '' ],
[column => 'atttypid,attnum,attbyval,attndims', '' ],
);
From 23fdf93b07c3e96cd626b3adea3420e44fd70d42 Mon Sep 17 00:00:00 2001
From: glynastill
Date: Tue, 8 Sep 2015 06:34:42 +0100
Subject: [PATCH 064/272] Fix typo: missing comma in commit
2e07159c2ecca1bd42950121ccb2f6fad762e30a
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index e2950155..4de0d414 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -6756,7 +6756,7 @@ sub check_same_schema {
indexprs,indcheckxmin,reltablespace,
indkey', '' ],
[trigger => 'tgqual,tgconstraint', '' ],
- [constraint => 'conbin,conindid,conkey,confkey
+ [constraint => 'conbin,conindid,conkey,confkey,
confmatchtype', '' ],
[column => 'atttypid,attnum,attbyval,attndims', '' ],
);
From 362890ebe8550f63fa48511f84997d4ff6dc94b3 Mon Sep 17 00:00:00 2001
From: glynastill
Date: Thu, 10 Sep 2015 10:53:43 +0100
Subject: [PATCH 065/272] Fix trigger check in check_same_schema to ignore
deferrable unique constraint triggers
These triggers have a name containting the triggers oid which mismatches on logical replicas; so to exclude these just ensure tgconstrindid is zero.
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 4de0d414..f3767348 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1102,7 +1102,7 @@ package check_postgres;
JOIN pg_namespace n3 ON (n3.oid = p.pronamespace)
LEFT JOIN pg_class c2 ON (c2.oid = t.tgconstrrelid)
LEFT JOIN pg_namespace n2 ON (n2.oid = c2.relnamespace)
-WHERE t.tgconstrrelid = 0 AND tgname !~ '^pg_'},
+WHERE t.tgconstrrelid = 0 AND t.tgconstrindid = 0 AND tgname !~ '^pg_'},
},
function => {
SQL => q{
From 59f11cd915c39f57c1ac73e8e966a0afdb3c34a5 Mon Sep 17 00:00:00 2001
From: glynastill
Date: Wed, 23 Sep 2015 14:26:07 +0100
Subject: [PATCH 066/272] Fix same_schema check so it considers left and right
operands when comparing operators.
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index f3767348..d79ef39b 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1066,7 +1066,7 @@ package check_postgres;
},
operator => {
SQL => q{
-SELECT o.*, o.oid, n.nspname||'.'||o.oprname AS name, quote_ident(o.oprname) AS safename,
+SELECT o.*, o.oid, n.nspname||'.'||o.oprname||' ('||COALESCE(t2.typname,'NONE')||','||COALESCE(t3.typname,'NONE')||')' AS name, quote_ident(o.oprname) AS safename,
rolname AS owner, n.nspname AS schema,
t1.typname AS resultname,
t2.typname AS leftname, t3.typname AS rightname,
From 6160c1218ce84bb2f67233838d2c3038a9a1f285 Mon Sep 17 00:00:00 2001
From: glyn
Date: Wed, 23 Dec 2015 12:35:12 +0000
Subject: [PATCH 067/272] same_schema: constraint unit test include table name
+ reinstate sequence last_value check.
Fixes for changes made to same_schema in commit f8145cd902b2c1e01bc211bbfc04737c5fee79f9
* Amend constraint unit tests in t/02_same_schema.t to take into account we now return the table name
* Reinstate checking of a sequences last_val, and instead allow users of asynchronous replication to override with '--assume-async' option
---
check_postgres.pl | 24 ++++++++++++++++++++----
t/02_same_schema.t | 18 ++++++++++++------
2 files changed, 32 insertions(+), 10 deletions(-)
mode change 100755 => 100644 check_postgres.pl
diff --git a/check_postgres.pl b/check_postgres.pl
old mode 100755
new mode 100644
index d79ef39b..f4993436
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1231,6 +1231,7 @@ package check_postgres;
'no-check_postgresrc',
'assume-standby-mode',
'assume-prod',
+ 'assume-async',
'action=s',
'warning=s',
@@ -1511,6 +1512,7 @@ package check_postgres;
Other options:
--assume-standby-mode assume that server in continious WAL recovery mode
--assume-prod assume that server in production mode
+ --assume-async assume that any replication is asynchronous
--PGBINDIR=PATH path of the postgresql binaries; avoid using if possible
--PSQL=FILE (deprecated) location of the psql executable; avoid using if possible
-v, --verbose verbosity level; can be used more than once to increase the level
@@ -6750,8 +6752,7 @@ sub check_same_schema {
[table => 'reltype,relfrozenxid,relminmxid,relpages,
reltuples,relnatts,relallvisible', '' ],
[view => 'reltype', '' ],
- [sequence => 'reltype,log_cnt,relnatts,is_called,
- last_value', '' ],
+ [sequence => 'reltype,log_cnt,relnatts,is_called', '' ],
[index => 'relpages,reltuples,indpred,indclass,
indexprs,indcheckxmin,reltablespace,
indkey', '' ],
@@ -7000,8 +7001,8 @@ sub check_same_schema {
next if $one eq '' and $two eq '-';
}
- ## If we are doing a historical comparison, skip some items
- if ($samedb) {
+ ## If we are doing a historical comparison or checking asynchronous replicas, skip some items
+ if ($samedb or $opt{'assume-async'}) {
if ($item eq 'sequence'
and $col eq 'last_value') {
next;
@@ -8592,6 +8593,14 @@ =head1 OTHER OPTIONS
postgres@db$./check_postgres.pl --action=checkpoint --datadir /var/lib/postgresql/8.3/main/ --assume-prod
POSTGRES_CHECKPOINT OK: Last checkpoint was 72 seconds ago | age=72;;300 mode=MASTER
+=item B<--assume-async>
+
+If specified, indicates that any replication between servers is asynchronous.
+The option is only relevant for (C).
+
+Example:
+ postgres@db$./check_postgres.pl --action=same_schema --assume-async --dbhost=star,line
+
=item B<-h> or B<--help>
Displays a help screen with a summary of all actions and options.
@@ -9836,6 +9845,9 @@ =head2 B
If you need to write the stored file to a specific direectory, use
the --audit-file-dir argument.
+To avoid false positives on value based checks caused by replication lag on
+asynchronous replicas, use the I<--assume-async> option.
+
To enable snapshots at various points in time, you can use the "--suffix"
argument to make the filenames unique to each run. See the examples below.
@@ -9864,6 +9876,10 @@ =head2 B
check_postgres_same_schema --dbname=cylon --suffix=daily --replace
+Example 7: Verify that two databases on hosts star and line are the same, excluding value data (i.e. sequence last_val):
+
+ check_postgres_same_schema --dbhost=star,line --assume-async
+
=head2 B
(C) Checks how much room is left on all sequences in the database.
diff --git a/t/02_same_schema.t b/t/02_same_schema.t
index ec70f5f6..ed31071d 100644
--- a/t/02_same_schema.t
+++ b/t/02_same_schema.t
@@ -340,6 +340,7 @@ Sequence "wakko.yakko" does not exist on all databases:
$t = qq{$S reports sequence differences};
$dbh2->do(q{CREATE SEQUENCE wakko.yakko MINVALUE 10 MAXVALUE 100 INCREMENT BY 3});
+
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
\s*Sequence "wakko.yakko":
@@ -493,7 +494,7 @@ like ($cp1->run($connect2),
\s*"relhastriggers" is different:
\s*Database 1: t
\s*Database 2: f
-\s*Trigger "public.tigger" does not exist on all databases:
+\s*Trigger "public.piglet.tigger" does not exist on all databases:
\s*Exists on: 1
\s*Missing on: 2\s*$}s,
$t);
@@ -509,7 +510,7 @@ $dbh2->do($SQL);
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
-\s*Trigger "public.tigger":
+\s*Trigger "public.piglet.tigger":
\s*"procname" is different:
\s*Database 1: bouncy
\s*Database 2: trouncy\s*}s,
@@ -525,7 +526,7 @@ $dbh1->do($SQL);
## We leave out the details as the exact values are version-dependent
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
-\s*Trigger "public.tigger":
+\s*Trigger "public.piglet.tigger":
\s*"tgenabled" is different:}s,
$t);
@@ -559,7 +560,7 @@ like ($cp1->run($connect2),
\s*"relchecks" is different:
\s*Database 1: 1
\s*Database 2: 0
-\s*Constraint "public.iscandar" does not exist on all databases:
+\s*Constraint "public.yamato.iscandar" does not exist on all databases:
\s*Exists on: 1
\s*Missing on: 2\s*$}s,
$t);
@@ -568,12 +569,17 @@ $t = qq{$S reports constraint with different definitions};
$dbh2->do(q{ALTER TABLE yamato ADD CONSTRAINT iscandar CHECK(nova > 256)});
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
-\s*Constraint "public.iscandar":
+\s*Constraint "public.yamato.iscandar":
\s*"consrc" is different:
\s*Database 1: \(nova > 0\)
-\s*Database 2: \(nova > 256\)\s*$}s,
+\s*Database 2: \(nova > 256\)
+\s*"constraintdef" is different:
+\s*Database 1: CHECK \(\(nova > 0\)\)
+\s*Database 2: CHECK \(\(nova > 256\)\)\s*$}s,
$t);
+
+
$t = qq{$S does not report constraint differences if the 'noconstraint' filter is given};
like ($cp1->run("$connect3 --filter=noconstraint,notables"), qr{^$label OK}, $t);
From 506a40846cc47a507c079e593b34a70f7b60e1a6 Mon Sep 17 00:00:00 2001
From: glyn
Date: Wed, 23 Dec 2015 10:58:14 +0000
Subject: [PATCH 068/272] Fix username field in check_txn_idle; broken when
adding support for objects owned by group roles in commit
d55287f1064c615ce2b0eb3cc3e2f6261f8070c4
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index f4993436..c04e9889 100644
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -8102,7 +8102,7 @@ sub check_txn_idle {
$whodunit = sprintf q{%s:%s %s:%s %s:%s%s%s %s:%s},
msg('PID'), $maxr->{pid},
msg('database'), $maxr->{datname},
- msg('username'), $maxr->{rolname},
+ msg('username'), $maxr->{usename},
$maxr->{client_addr} eq '' ? '' : (sprintf ' %s:%s', msg('address'), $maxr->{client_addr}),
($maxr->{client_port} eq '' or $maxr->{client_port} < 1)
? '' : (sprintf ' %s:%s', msg('port'), $maxr->{client_port}),
From e32a89302830a5dc75ad524fab3642ce8981d4ca Mon Sep 17 00:00:00 2001
From: glynastill
Date: Thu, 16 Apr 2015 13:26:37 +0100
Subject: [PATCH 069/272] Fix "--filter" logic to honour regular expressions
As per the manual:
"To exclude objects of a certain type by a regular expression against their name, use "noname=regex"."
However the actual check in the script would only filter on an exact match; switched to regex.
---
check_postgres.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index c04e9889..608f1dbd 100644
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -7260,7 +7260,7 @@ sub schema_item_exists {
for my $name (sort keys %{ $itemhash->{$db1}{$item_class} }) {
## Can exclude by 'filter' based regex
- next if grep { $name eq $_ } @$exclude_regex;
+ next if grep { $name =~ $_ } @$exclude_regex;
if (! exists $itemhash->{$db2}{$item_class}{$name}) {
@@ -7336,7 +7336,7 @@ sub schema_item_differences {
for my $name (sort keys %{ $itemhash->{$db1}{$item_class} }) {
## Can exclude by 'filter' based regex
- next if grep { $name eq $_ } @$exclude_regex;
+ next if grep { $name =~ $_ } @$exclude_regex;
## This case has already been handled:
next if ! exists $itemhash->{$db2}{$item_class}{$name};
From 9ce42ea503e4d049566e0e2c8f42df0a1a0f29ab Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 7 Jun 2016 14:28:19 +0200
Subject: [PATCH 070/272] Do some whitespace cleanup
... and add a changelog entry for the same_schema fixes by Glyn.
---
check_postgres.pl | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 608f1dbd..456fbd5c 100644
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -382,7 +382,7 @@ package check_postgres;
'checkpoint-po' => q{Instante del último checkpoint:},
'checksum-msg' => q{checksum: $1},
'checksum-nomd' => q{Debe instalar el módulo Perl Digest::MD5 para usar la acción checksum},
- 'checksum-nomrtg' => q{Debe proporcionar un checksum con la opción --mrtg},
+ 'checksum-nomrtg' => q{Debe proporcionar un checksum con la opción --mrtg},
'custom-invalid' => q{Formato devuelto por la consulta personalizada es inválido},
'custom-norows' => q{No se obtuvieron filas},
'custom-nostring' => q{Debe proporcionar el texto con la consulta},
@@ -447,7 +447,7 @@ package check_postgres;
'no-match-set' => q{No se encuentran opciones de configuración coincidentes debido a las opciones de exclusión/inclusión},
'no-match-table' => q{No se encuentran tablas coincidentes debido a las opciones de exclusión/inclusión},
'no-match-user' => q{No se encuentran entradas coincidentes debido a las opciones de exclusión/inclusión},
- 'no-match-slot' => q{No se encuentran ranuras de replicación coincidentes debido a las opciones de exclusión/inclusión},
+ 'no-match-slot' => q{No se encuentran ranuras de replicación coincidentes debido a las opciones de exclusión/inclusión},
'no-match-slotok' => q{No se encuentran ranuras de replicación},
'no-parse-psql' => q{No se pudo interpretar la salida de psql!},
'no-time-hires' => q{No se encontró Time::HiRes, necesario si 'showtime' es verdadero},
@@ -503,7 +503,7 @@ package check_postgres;
'range-warnbigsize' => q{El valor de la opción 'warning' ($1 bytes) no puede ser mayor que el de 'critical ($2 bytes)'},
'range-warnbigtime' => q{El valor de la opción 'warning' ($1 s) no puede ser mayor que el de 'critical ($2 s)'},
'range-warnsmall' => q{El valor de la opción 'warning' no puede ser menor que el de 'critical'},
- 'range-nointfortime' => q{Valor inválido para las opciones '$1': debe ser un entero o un valor de tiempo},
+ 'range-nointfortime' => q{Valor inválido para las opciones '$1': debe ser un entero o un valor de tiempo},
'relsize-msg-ind' => q{el índice más grande es "$1": $2},
'relsize-msg-reli' => q{la relación más grande es el índice "$1": $2},
'relsize-msg-relt' => q{la relación más grande es la tabla "$1": $2},
@@ -1512,7 +1512,7 @@ package check_postgres;
Other options:
--assume-standby-mode assume that server in continious WAL recovery mode
--assume-prod assume that server in production mode
- --assume-async assume that any replication is asynchronous
+ --assume-async assume that any replication is asynchronous
--PGBINDIR=PATH path of the postgresql binaries; avoid using if possible
--PSQL=FILE (deprecated) location of the psql executable; avoid using if possible
-v, --verbose verbosity level; can be used more than once to increase the level
@@ -3883,9 +3883,9 @@ sub check_bloat {
FROM pg_stats s2
WHERE null_frac<>0 AND s2.schemaname = ns.nspname AND s2.tablename = tbl.relname
) AS nullhdr
- FROM pg_attribute att
+ FROM pg_attribute att
JOIN pg_class tbl ON att.attrelid = tbl.oid
- JOIN pg_namespace ns ON ns.oid = tbl.relnamespace
+ JOIN pg_namespace ns ON ns.oid = tbl.relnamespace
LEFT JOIN pg_stats s ON s.schemaname=ns.nspname
AND s.tablename = tbl.relname
AND s.inherited=false
@@ -4846,9 +4846,9 @@ sub check_fsm_pages {
(my $c = $critical) =~ s/\D//;
my $SQL = q{
SELECT pages, maxx, ROUND(100*(pages/maxx)) AS percent
-FROM
+FROM
(SELECT (sumrequests+numrels)*chunkpages AS pages
- FROM (SELECT SUM(CASE WHEN avgrequest IS NULL
+ FROM (SELECT SUM(CASE WHEN avgrequest IS NULL
THEN interestingpages/32 ELSE interestingpages/16 END) AS sumrequests,
COUNT(relfilenode) AS numrels, 16 AS chunkpages FROM pg_freespacemap_relations) AS foo) AS foo2,
(SELECT setting::NUMERIC AS maxx FROM pg_settings WHERE name = 'max_fsm_pages') AS foo3
@@ -4908,7 +4908,7 @@ sub check_fsm_relations {
my $SQL = q{
SELECT maxx, cur, ROUND(100*(cur/maxx)) AS percent
-FROM (SELECT
+FROM (SELECT
(SELECT COUNT(*) FROM pg_freespacemap_relations) AS cur,
(SELECT setting::NUMERIC FROM pg_settings WHERE name='max_fsm_relations') AS maxx) x
};
@@ -5204,7 +5204,7 @@ sub check_replication_slots {
slot_type,
coalesce(restart_lsn, '0/0'::pg_lsn) AS slot_lsn,
coalesce(pg_xlog_location_diff(pg_current_xlog_location(), restart_lsn),0) AS delta,
- active
+ active
FROM pg_replication_slots)
SELECT *, pg_size_pretty(delta) AS delta_pretty FROM slots;
};
@@ -5215,7 +5215,7 @@ sub check_replication_slots {
my $info = run_command($SQL, { regex => qr{\d+}, emptyok => 1, } );
my $found = 0;
-
+
for $db (@{$info->{db}}) {
my $max = -1;
$found = 1;
@@ -5224,7 +5224,7 @@ sub check_replication_slots {
for my $r (@{$db->{slurp}}) {
if (skip_item($r->{slot_name})) {
$max = -2 if ($max == -1 );
- next;
+ next;
}
if ($r->{delta} >= $max) {
$max = $r->{delta};
@@ -6329,7 +6329,7 @@ sub check_query_runtime {
## Valid units: s[econd], m[inute], h[our], d[ay]
## Does a "EXPLAIN ANALYZE SELECT COUNT(1) FROM xyz"
## where xyz is given by the option --queryname
- ## This could also be a table or a function, or course, but must be a
+ ## This could also be a table or a function, or course, but must be a
## single word. If a function, it must be empty (with "()")
## Examples:
## --warning="100s" --critical="120s" --queryname="speedtest1"
@@ -6748,7 +6748,7 @@ sub check_same_schema {
[schema => '', '' ],
[function => 'source_checksum,prolang,prorettype,
proargtypes,proallargtypes,provariadic,
- proargdefaults', '' ],
+ proargdefaults', '' ],
[table => 'reltype,relfrozenxid,relminmxid,relpages,
reltuples,relnatts,relallvisible', '' ],
[view => 'reltype', '' ],
@@ -7552,7 +7552,7 @@ sub find_catalog_info {
if (exists $ci->{innerSQL}) {
if ($type eq 'sequence') {
- ## If this is a sequence, we want to grab them all at once to reduce
+ ## If this is a sequence, we want to grab them all at once to reduce
## the amount of round-trips we do with 'SELECT * FROM seqname'
if (! exists $opt{seqinfoss}{$dbnum}) {
$SQL = q{SELECT quote_ident(nspname)||'.'||quote_ident(relname) AS sname }
@@ -8172,7 +8172,7 @@ sub check_txn_idle {
sub check_txn_time {
- ## This is the same as check_txn_idle, but we want where the
+ ## This is the same as check_txn_idle, but we want where the
## transaction start time is not null
check_txn_idle('txntime',
@@ -10319,6 +10319,8 @@ =head1 HISTORY
New action replication_slots checking if logical or physical replication
slots have accumulated too much data
+
+ Multiple same_schema improvements
(Glyn Astill)
Add Spanish message translations
From 38ac36d4ec0a3a8a9ac8bf537bc2b1ef34e86c3a Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 7 Jun 2016 15:14:51 +0200
Subject: [PATCH 071/272] Fix same_schema on 8.4
---
check_postgres.pl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 456fbd5c..017bed16 100644
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -7471,6 +7471,9 @@ sub find_catalog_info {
$SQL = $ci->{SQL2};
}
}
+ if ($type eq 'trigger' and $dbver->{major} <= 8.4) {
+ $SQL =~ s/t.tgconstrindid = 0 AND //;
+ }
if (exists $ci->{exclude}) {
if ('temp_schemas' eq $ci->{exclude}) {
From 6a7dacc0a325960d2b2c525ce5d347fe7946da84 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 7 Jun 2016 15:39:39 +0200
Subject: [PATCH 072/272] Convert README to Markdown
---
README => README.md | 52 ++++++++++++++++++++++++---------------------
1 file changed, 28 insertions(+), 24 deletions(-)
rename README => README.md (78%)
diff --git a/README b/README.md
similarity index 78%
rename from README
rename to README.md
index 9063c8dd..ef7a0811 100644
--- a/README
+++ b/README.md
@@ -1,58 +1,62 @@
-check_postgres is Copyright (C) 2007-2015, Greg Sabino Mullane
+check_postgres
+==============
This is check_postgres, a monitoring tool for Postgres.
The most complete and up to date information about this script can be found at:
-http://bucardo.org/check_postgres/
+https://bucardo.org/wiki/Check_postgres
You should go check there right now to make sure you are installing
the latest version!
This document will cover how to install the script.
-* Quick method:
+Quick method
+------------
For the impatient Nagios admin, just copy the "check_postgres.pl" file
to your Nagios scripts directory, and perhaps symlink entries to that
file by:
-cd
-mkdir postgres
-cd postgres
-perl ../check_postgres.pl --symlinks
+ cd
+ mkdir postgres
+ cd postgres
+ perl ../check_postgres.pl --symlinks
Then join the announce mailing list (see below)
-* Complete method:
+Complete method
+---------------
The better way to install this script is via the standard Perl process:
-perl Makefile.PL
-make
-make test
-make install
+ perl Makefile.PL
+ make
+ make test
+ make install
The last step usually needs to be done as the root user. You may want to
copy the script to a place that makes more sense for Nagios, if using it
for that purpose. See the "Quick" instructions above.
-For 'make test', please report any failing tests to check_postgres@bucardo.org.
+For `make test`, please report any failing tests to check_postgres@bucardo.org.
The tests need to have some standard Postgres binaries available, such as
-'initdb', 'psql', and 'pg_ctl'. If these are not in your path, or you want to
-use specific ones, please set the environment variable PGBINDIR first.
+`initdb`, `psql`, and `pg_ctl`. If these are not in your path, or you want to
+use specific ones, please set the environment variable `PGBINDIR` first.
-Once 'make install' has been done, you should have access to the complete
+Once `make install` has been done, you should have access to the complete
documentation by typing:
-man check_postgres
+ man check_postgres
The HTML version of the documentation is also available at:
-http://bucardo.org/check_postgres/check_postgres.pl.html
+https://bucardo.org/check_postgres/check_postgres.pl.html
-* Mailing lists
+Mailing lists
+-------------
The final step should be to subscribe to the low volume check_postgres-announce
mailing list, so you learn of new versions and important changes. Information
@@ -67,20 +71,20 @@ https://mail.endcrypt.com/mailman/listinfo/check_postgres
Development happens via git. You can check out the repository by doing:
-git clone git://bucardo.org/check_postgres.git
+ git clone git://bucardo.org/check_postgres.git
All changes are sent to the commit list:
https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit
-COPYRIGHT:
-----------
+COPYRIGHT
+---------
Copyright (c) 2007-2015 Greg Sabino Mullane
-LICENSE INFORMATION:
---------------------
+LICENSE INFORMATION
+-------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
From e371eb86b4de4a992b94cdd8fe9b1af0932fea33 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 7 Jun 2016 15:53:14 +0200
Subject: [PATCH 073/272] Update MANIFEST
---
MANIFEST | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/MANIFEST b/MANIFEST
index c320ac26..4fc6dca9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,7 +1,7 @@
check_postgres.pl
check_postgres.pl.asc
check_postgres.pl.html
-README
+README.md
SIGNATURE
Makefile.PL
MANIFEST
@@ -12,6 +12,7 @@ MYMETA.yml
TODO
t/00_basic.t
+t/00_release.t
t/00_signature.t
t/00_test_tester.t
t/01_validate_range.t
@@ -47,6 +48,7 @@ t/02_query_runtime.t
t/02_query_time.t
t/02_relation_size.t
t/02_replicate_row.t
+t/02_replication_slots.t
t/02_same_schema.t
t/02_sequence.t
t/02_settings_checksum.t
@@ -61,4 +63,7 @@ t/03_translations.t
t/04_timeout.t
t/05_docs.t
t/99_cleanup.t
+t/99_perlcritic.t
+t/99_pod.t
+t/99_spellcheck.t
t/CP_Testing.pm
From fd9eb2820b5bc7a45b9137c2c0e0d9a55141cb67 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 7 Jun 2016 20:54:02 +0200
Subject: [PATCH 074/272] t/02_replicate_row.t: Allow for some variation in the
replication time
---
t/02_replicate_row.t | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/02_replicate_row.t b/t/02_replicate_row.t
index 7df6354d..84f61080 100644
--- a/t/02_replicate_row.t
+++ b/t/02_replicate_row.t
@@ -141,8 +141,8 @@ else {
$t=qq{$S works when rows match, with MRTG output};
$dbh->commit();
if (fork) {
- is ($cp->run('DB2replicate-row', '-c 20 --output=MRTG -repinfo=reptest,id,1,foo,yin,yang'),
- qq{1\n0\n\n\n}, $t);
+ like ($cp->run('DB2replicate-row', '-c 20 --output=MRTG -repinfo=reptest,id,1,foo,yin,yang'),
+ qr{^[12]\n0\n\n\n}, $t);
}
else {
usleep 500_000; # 0.5s
From 596c506ed0b784b313cf1aeee7bb2d114c880d9e Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 7 Jun 2016 22:57:28 +0200
Subject: [PATCH 075/272] t/02_replicate_row.t: wait for the forks, and sleep a
bit longer
Hopefully this will make the test more reliable.
---
t/02_replicate_row.t | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/t/02_replicate_row.t b/t/02_replicate_row.t
index 84f61080..d8a63f97 100644
--- a/t/02_replicate_row.t
+++ b/t/02_replicate_row.t
@@ -7,7 +7,6 @@ use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 19;
-use Time::HiRes qw(usleep);
use lib 't','.';
use CP_Testing;
@@ -120,6 +119,7 @@ else {
$dbh2->commit();
exit;
}
+wait;
$t=qq{$S works when rows match, reports proper delay};
$dbh->commit();
@@ -137,20 +137,22 @@ else {
$dbh2->commit();
exit;
}
+wait;
$t=qq{$S works when rows match, with MRTG output};
$dbh->commit();
if (fork) {
like ($cp->run('DB2replicate-row', '-c 20 --output=MRTG -repinfo=reptest,id,1,foo,yin,yang'),
- qr{^[12]\n0\n\n\n}, $t);
+ qr{^[1-5]\n0\n\n\n}, $t);
}
else {
- usleep 500_000; # 0.5s
+ sleep 1;
$SQL = q{UPDATE reptest SET foo = 'yin' WHERE id = 1};
$dbh2->do($SQL);
$dbh2->commit();
exit;
}
+wait;
$t=qq{$S works when rows match, with simple output};
$dbh->commit();
@@ -167,6 +169,7 @@ else {
$dbh2->commit();
exit;
}
+wait;
$dbh2->disconnect();
From c09e7840ed82db6274116ce9b83fbdbc72f940c8 Mon Sep 17 00:00:00 2001
From: Sebastian Webber
Date: Fri, 13 Mar 2015 10:11:08 -0300
Subject: [PATCH 076/272] adjusting check_txn_idle filter by state_change
column
---
check_postgres.pl | 1 +
1 file changed, 1 insertion(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 017bed16..d42b5abf 100644
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -8019,6 +8019,7 @@ sub check_txn_idle {
$SQL3 =~ s/current_query NOT LIKE '%'/(state NOT LIKE 'idle%' OR state IS NULL)/; # query_time
$SQL3 =~ s/current_query/query/g;
$SQL3 =~ s/'' AS state/state AS state/;
+ $SQL3 =~ s/query_start/state_change/g;
my $info = run_command($SQL, { emptyok => 1 , version => [ "<8.3 $SQL2", ">9.1 $SQL3" ] } );
From a3cf9dacf3b5bc5db7410f7f43325780b20cd5ea Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 7 Jun 2016 23:27:46 +0200
Subject: [PATCH 077/272] Add changelog for
c09e7840ed82db6274116ce9b83fbdbc72f940c8.
---
check_postgres.pl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index d42b5abf..222f9a5a 100644
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -10346,6 +10346,9 @@ =head1 HISTORY
check_txn_idle: Don't fail when query contains 'disabled' word
(Marco Nenciarini)
+ check_txn_idle: Use state_change instead of query_start.
+ (Sebastian Webber)
+
check_hot_standby_delay: Correct extra space in perfdata
(Adrien Nayrat)
From 735515a682a6ece76054ba5ceb8b25d0a55ff312 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Wed, 8 Jun 2016 10:23:27 +0200
Subject: [PATCH 078/272] hot_standby_delay: Check server version instead of
psql version for features
In passing, make check_postgres.pl executable
Close #74.
---
check_postgres.pl | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
mode change 100644 => 100755 check_postgres.pl
diff --git a/check_postgres.pl b/check_postgres.pl
old mode 100644
new mode 100755
index 222f9a5a..2fa13d22
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -3020,7 +3020,7 @@ sub verify_version {
}
$db->{slurp} = $oldslurp;
- return;
+ return $sver;
} ## end of verify_version
@@ -5049,8 +5049,10 @@ sub check_hot_standby_delay {
## --warning=5min
## --warning='1048576 and 2min' --critical='16777216 and 10min'
+ my $version = verify_version();
+
my ($warning, $wtime, $critical, $ctime) = validate_integer_for_time({default_to_int => 1});
- if ($psql_version < 9.1 and (length $wtime or length $ctime)) { # FIXME: check server version instead
+ if ($version < 9.1 and (length $wtime or length $ctime)) {
add_unknown msg('hs-time-version');
return;
}
@@ -5090,7 +5092,7 @@ sub check_hot_standby_delay {
## On slave
$SQL = q{SELECT pg_last_xlog_receive_location() AS receive, pg_last_xlog_replay_location() AS replay};
- if ($psql_version >= 9.1) {
+ if ($version >= 9.1) {
$SQL .= q{, COALESCE(ROUND(EXTRACT(epoch FROM now() - pg_last_xact_replay_timestamp())),0) AS seconds};
}
my $info = run_command($SQL, { dbnumber => $slave, regex => qr/\// });
@@ -5149,7 +5151,7 @@ sub check_hot_standby_delay {
return;
}
- $MRTG and do_mrtg($psql_version >= 9.1 ?
+ $MRTG and do_mrtg($version >= 9.1 ?
{one => $rep_delta, two => $rec_delta, three => $time_delta} :
{one => $rep_delta, two => $rec_delta});
@@ -5161,14 +5163,14 @@ sub check_hot_standby_delay {
$db->{perf} .= sprintf ' %s=%s;%s;%s',
perfname(msg('hs-receive-delay')), $rec_delta, $warning, $critical;
}
- if ($psql_version >= 9.1) {
+ if ($version >= 9.1) {
$db->{perf} .= sprintf ' %s=%s;%s;%s',
perfname(msg('hs-time-delay')), $time_delta, $wtime, $ctime;
}
## Do the check on replay delay in case SR has disconnected because it way too far behind
my $msg = qq{$rep_delta};
- if ($psql_version >= 9.1) {
+ if ($version >= 9.1) {
$msg .= qq{ and $time_delta seconds}
}
if ((length $critical or length $ctime) and (!length $critical or length $critical and $rep_delta > $critical) and (!length $ctime or length $ctime and $time_delta > $ctime)) {
From c2e378122b5b20abf7ab69476296a5307733def0 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Wed, 8 Jun 2016 12:00:14 +0200
Subject: [PATCH 079/272] Update query_time docs to match actual code
Close #63.
---
check_postgres.pl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 2fa13d22..afb3b27a 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -9714,7 +9714,7 @@ =head2 B
See the L"USER NAME FILTERING"> section for more details.
The values for the I<--warning> and I<--critical> options are amounts of
-time, and default to '2 minutes' and '5 minutes' respectively. Valid units
+time, and at least one must be provided (no defaults). Valid units
are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or
abbreviated to just the first letter. If no units are given, the unit is
assumed to be seconds.
@@ -9980,7 +9980,7 @@ =head2 B
section below for more details.
The I<--warning> and I<--critical> options are given as units of time, signed
-integers, or integers for units of time, and both must be provided (there are
+integers, or integers for units of time, and at least one must be provided (there are
no defaults). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each
may be written singular or abbreviated to just the first letter. If no units
are given and the numbers are unsigned, the units are assumed to be seconds.
@@ -10014,7 +10014,7 @@ =head2 B
See the L"USER NAME FILTERING"> section for more details.
The values or the I<--warning> and I<--critical> options are units of time, and
-must be provided (no default). Valid units are 'seconds', 'minutes', 'hours',
+at least one must be provided (no default). Valid units are 'seconds', 'minutes', 'hours',
or 'days'. Each may be written singular or abbreviated to just the first letter.
If no units are given, the units are assumed to be seconds.
From 0984bbc4effc2bcc64ac53c5957ce23e1def832a Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Wed, 8 Jun 2016 13:42:44 +0200
Subject: [PATCH 080/272] connection: Make all errors including timeout from
psql CRITICAL
UNKNOWN is not so much useful in the context of basic connection checks.
(The result remains UNKNOWN in case version() returns something fishy.)
Close #100.
---
check_postgres.pl | 18 ++++++++++++++----
t/02_connection.t | 11 +++++++++--
t/CP_Testing.pm | 25 +++++++++++++++++++++++++
3 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index afb3b27a..84065bad 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2624,7 +2624,7 @@ sub run_command {
}
}
- local $SIG{ALRM} = sub { die 'Timed out' };
+ local $SIG{ALRM} = sub { die "Timed out\n" };
alarm 0;
push @args, '-c', $string;
@@ -2642,6 +2642,10 @@ sub run_command {
alarm 0;
open STDERR, '>&', $oldstderr or ndie msg('runcommand-noerr');
close $oldstderr or ndie msg('file-noclose', 'STDERR copy', $!);
+ if ($err and $action eq 'connection') {
+ $info->{fatal} = $err;
+ return $info;
+ }
if ($err) {
if ($err =~ /Timed out/) {
ndie msg('runcommand-timeout', $timeout);
@@ -2666,8 +2670,8 @@ sub run_command {
}
## If we are just trying to connect, failed attempts are critical
- if ($action eq 'connection' and $db->{error} =~ /FATAL|could not connect/) {
- $info->{fatal} = 1;
+ if ($action eq 'connection' and $db->{error}) {
+ $info->{fatal} = $db->{error};
return $info;
}
@@ -4325,11 +4329,15 @@ sub check_connection {
}
my $info = run_command('SELECT version() AS v');
+ if ($info->{fatal}) {
+ add_critical $info->{fatal};
+ return;
+ }
for $db (@{$info->{db}}) {
my $err = $db->{error} || '';
- if ($err =~ /FATAL|could not connect/) {
+ if ($err) {
$MRTG and do_mrtg({one => 0});
add_critical $db->{error};
return;
@@ -10321,6 +10329,8 @@ =head1 HISTORY
total_relation_size, using the respective pg_indexes_size() and
pg_total_relation_size() functions. All size checks will now also check
materialized views where applicable.
+
+ Connection errors are now always critical, not unknown.
(Christoph Berg)
New action replication_slots checking if logical or physical replication
diff --git a/t/02_connection.t b/t/02_connection.t
index d6fd219e..20839ae3 100644
--- a/t/02_connection.t
+++ b/t/02_connection.t
@@ -6,7 +6,7 @@ use 5.006;
use strict;
use warnings;
use Data::Dumper;
-use Test::More tests => 12;
+use Test::More tests => 14;
use lib 't','.';
use CP_Testing;
@@ -52,7 +52,14 @@ is ($cp->run('--output=MRTG'), qq{1\n0\n\n\n}, $t);
$cp->fake_version('ABC');
$t=qq{$S fails if there's a fake version function};
-like ($cp->run(), qr{^$label UNKNOWN:}, $t);
+like ($cp->run(), qr{^$label UNKNOWN:.*Invalid query}, $t);
+
+$cp->fake_version_timeout();
+$t=qq{$S fails on timeout};
+like ($cp->run('--timeout 1'), qr{^$label CRITICAL:.*Timed out}, $t);
$cp->reset_path();
+$t=qq{$S fails on nonexisting socket};
+like ($cp->run('--port=1023'), qr{^$label CRITICAL: could not connect to server}, $t);
+
exit;
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 0ed72874..3ff08789 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -767,6 +767,31 @@ SELECT 'PostgreSQL $version on fakefunction for check_postgres.pl testing'::text
} ## end of fake version
+sub fake_version_timeout {
+
+ my $self = shift;
+ my $dbh = $self->{dbh} || die;
+ my $dbuser = $self->{testuser} || die;
+
+ if (! $self->schema_exists($dbh, $fakeschema)) {
+ $dbh->do("CREATE SCHEMA $fakeschema");
+ }
+
+ $dbh->do(qq{
+CREATE OR REPLACE FUNCTION $fakeschema.version()
+RETURNS TEXT
+LANGUAGE SQL
+AS \$\$
+SELECT pg_sleep(10)::text;
+\$\$
+});
+ $dbh->do("ALTER USER $dbuser SET search_path = $fakeschema, public, pg_catalog");
+ $dbh->commit();
+ return;
+
+} ## end of fake version timeout
+
+
sub fake_self_version {
## Look out...
From 3d6f175a9303753b7a36a59d4179d21b5e5d9a02 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Wed, 8 Jun 2016 22:14:59 +0200
Subject: [PATCH 081/272] txn_idle: Document that --includeuser can be used to
work around superuser checks
Close #81.
---
check_postgres.pl | 4 ++++
t/02_txn_idle.t | 10 ++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 84065bad..76514448 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -9995,6 +9995,10 @@ =head2 B
This action requires Postgres 8.3 or better.
+Superuser privileges are required to see the queries of all users in the system;
+UNKNOWN is returned if queries cannot be checked. To only include queries by
+the connecting user, use I<--includeuser>.
+
Example 1: Give a warning if any connection has been idle in transaction for more than 15 seconds:
check_postgres_txn_idle --port=5432 --warning='15 seconds'
diff --git a/t/02_txn_idle.t b/t/02_txn_idle.t
index 0f841a3b..87efe4ce 100644
--- a/t/02_txn_idle.t
+++ b/t/02_txn_idle.t
@@ -6,7 +6,7 @@ use 5.006;
use strict;
use warnings;
use Data::Dumper;
-use Test::More tests => 15;
+use Test::More tests => 16;
use lib 't','.';
use CP_Testing;
@@ -84,9 +84,15 @@ like ($cp->run(q{-w '1 for 2s'}), qr{1 idle transactions longer than 2s, longest
$t = qq{$S returns an unknown if running as a non-superuser};
my $olduser = $cp->{testuser};
$cp->{testuser} = 'powerless_pete';
-like ($cp->run('-w 0'), qr{^$label UNKNOWN: .+superuser}, $t);
+like ($cp->run('-w 1'), qr{^$label UNKNOWN: .+superuser}, $t);
$idle_dbh->commit;
+my $idle_dbh2 = $cp->test_database_handle({ testuser => 'powerless_pete' });
+$idle_dbh2->do('SELECT 1');
+sleep(1);
+$t = qq{$S identifies own queries even when running as a non-superuser};
+like ($cp->run('-w 1 --includeuser powerless_pete'), qr{longest idle in txn: \d+s}, $t);
+
exit;
From e963338ac493149a3b7bd222b4ea97b0876f5e92 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Thu, 22 Sep 2016 15:15:09 +0200
Subject: [PATCH 082/272] t/02_disk_space.t: Further relax device name check
In the wild (Debian sbuild) a CP output of "FS sid-pgdg-amd64-sbuild
mounted on /" was observed. Stop requiring the device name to start with
/ or -, and go with .* instead.
---
t/02_disk_space.t | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/02_disk_space.t b/t/02_disk_space.t
index 24d887f7..1b58ccdc 100644
--- a/t/02_disk_space.t
+++ b/t/02_disk_space.t
@@ -39,7 +39,7 @@ $t = qq{$S identifies host};
like ($result, qr{host:$host}, $t);
$t = qq{$S reports file system};
-like ($result, qr{FS [/-].*? mounted on /.*? is using }, $t); # in some build environments, the filesystem is reported as "-"
+like ($result, qr{FS .* mounted on /.*? is using }, $t); # in some build environments, the filesystem is reported as "-"
$t = qq{$S reports usage};
like ($result, qr{ is using \d*\.\d+ [A-Z]B of \d*\.\d+ [A-Z]B}, $t);
@@ -54,6 +54,6 @@ $t = qq{$S flags insufficient space};
like ($cp->run('-w "999z or 1%"'), qr{$label WARNING:}, $t);
$t = qq{$S reports MRTG output};
-like ($cp->run('--output=mrtg'), qr{\A\d+\n0\n\n[/-].*\n}, $t);
+like ($cp->run('--output=mrtg'), qr{\A\d+\n0\n\n.*\n}, $t);
exit;
From 1b5e40ad48cbff705e822521b6a0c591521fcd9d Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Mon, 26 Sep 2016 11:41:07 +0200
Subject: [PATCH 083/272] t/02_txn_time.t: Allow some time slack
---
t/02_txn_time.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/02_txn_time.t b/t/02_txn_time.t
index d743fe1f..cd196233 100644
--- a/t/02_txn_time.t
+++ b/t/02_txn_time.t
@@ -73,7 +73,7 @@ $t = qq{$S identifies a one-second running txn};
my $idle_dbh = $cp->test_database_handle();
$idle_dbh->do('SELECT 1');
sleep(1);
-like ($cp->run(q{-w 0}), qr{longest txn: 1s}, $t);
+like ($cp->run(q{-w 0}), qr{longest txn: [12]s}, $t);
$t .= ' (MRTG)';
my $query_patten = ($ver >= 90200) ? "SELECT 1" : " in transaction";
From c916b5ffa3c816ada8ce112fcf466c3d8d986e76 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Wed, 28 Sep 2016 14:20:47 -0400
Subject: [PATCH 084/272] Remove some tabs
---
t/00_release.t | 70 +++++++++++++++++++++++------------------------
t/99_perlcritic.t | 22 +++++++--------
t/99_spellcheck.t | 14 +++++-----
3 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/t/00_release.t b/t/00_release.t
index 36604b70..efac6b4f 100644
--- a/t/00_release.t
+++ b/t/00_release.t
@@ -20,8 +20,8 @@ my $file = 'MANIFEST';
my @mfiles;
open my $mfh, '<', $file or die qq{Could not open "$file": $!\n};
while (<$mfh>) {
- next if /^#/;
- push @mfiles => $1 if /(\S.+)/o;
+ next if /^#/;
+ push @mfiles => $1 if /(\S.+)/o;
}
close $mfh or warn qq{Could not close "$file": $!\n};
@@ -108,43 +108,43 @@ else {
## Make sure all files in the MANIFEST are "clean": no tabs, no unusual characters
for my $mfile (@mfiles) {
- file_is_clean($mfile);
+ file_is_clean($mfile);
}
sub file_is_clean {
- my $file = shift or die; ## no critic (ProhibitReusedNames)
-
- if (!open $fh, '<', $file) {
- fail qq{Could not open "$file": $!\n};
- return;
- }
- $good = 1;
- my $inside_copy = 0;
- while (<$fh>) {
- if (/^COPY .+ FROM stdin/i) {
- $inside_copy = 1;
- }
- if (/^\\./ and $inside_copy) {
- $inside_copy = 0;
- }
- if (/\t/ and $file ne 'Makefile.PL' and $file !~ /\.html$/ and ! $inside_copy) {
- diag "Found a tab at line $. of $file\n";
- $good = 0;
- }
- if (! /^[\S ]*/) {
- diag "Invalid character at line $. of $file: $_\n";
- $good = 0; die;
- }
- }
- close $fh or warn qq{Could not close "$file": $!\n};
-
- if ($good) {
- pass "The $file file has no tabs or unusual characters";
- }
- else {
- fail "The $file file did not pass inspection!";
- }
+ my $file = shift or die; ## no critic (ProhibitReusedNames)
+
+ if (!open $fh, '<', $file) {
+ fail qq{Could not open "$file": $!\n};
+ return;
+ }
+ $good = 1;
+ my $inside_copy = 0;
+ while (<$fh>) {
+ if (/^COPY .+ FROM stdin/i) {
+ $inside_copy = 1;
+ }
+ if (/^\\./ and $inside_copy) {
+ $inside_copy = 0;
+ }
+ if (/\t/ and $file ne 'Makefile.PL' and $file !~ /\.html$/ and ! $inside_copy) {
+ diag "Found a tab at line $. of $file\n";
+ $good = 0;
+ }
+ if (! /^[\S ]*/) {
+ diag "Invalid character at line $. of $file: $_\n";
+ $good = 0; die;
+ }
+ }
+ close $fh or warn qq{Could not close "$file": $!\n};
+
+ if ($good) {
+ pass "The $file file has no tabs or unusual characters";
+ }
+ else {
+ fail "The $file file did not pass inspection!";
+ }
}
diff --git a/t/99_perlcritic.t b/t/99_perlcritic.t
index 4a1e449e..5bed531d 100644
--- a/t/99_perlcritic.t
+++ b/t/99_perlcritic.t
@@ -41,17 +41,17 @@ for my $filename (qw{Makefile.PL check_postgres.pl t/CP_Testing.pm}) {
-e $filename or die qq{Could not find "$filename"!};
open my $oldstderr, '>&', \*STDERR or die 'Could not dupe STDERR';
close STDERR or die qq{Could not close STDERR: $!};
- my @vio;
- my $ranok = 0;
- eval {
- @vio = $critic->critique($filename);
- $ranok = 1;
- };
- if (! $ranok) {
- pass "Perl::Critic failed for file $filename. Error was: $@\n";
- $@ = undef;
- next;
- }
+ my @vio;
+ my $ranok = 0;
+ eval {
+ @vio = $critic->critique($filename);
+ $ranok = 1;
+ };
+ if (! $ranok) {
+ pass "Perl::Critic failed for file $filename. Error was: $@\n";
+ $@ = undef;
+ next;
+ }
open STDERR, '>&', $oldstderr or die 'Could not recreate STDERR'; ## no critic
close $oldstderr or die qq{Could not close STDERR copy: $!};
my $vios = 0;
diff --git a/t/99_spellcheck.t b/t/99_spellcheck.t
index 37a6f801..070b28d0 100644
--- a/t/99_spellcheck.t
+++ b/t/99_spellcheck.t
@@ -79,19 +79,19 @@ SKIP: {
skip 'Need Pod::Text to re-test the spelling of embedded POD', 1;
}
- my $parser = Pod::Text->new (quotes => 'none');
+ my $parser = Pod::Text->new (quotes => 'none');
for my $file (qw{check_postgres.pl}) {
if (! -e $file) {
fail(qq{Could not find the file "$file"!});
}
- my $string;
- my $tmpfile = "$file.tmp";
+ my $string;
+ my $tmpfile = "$file.tmp";
$parser->parse_from_file($file, $tmpfile);
- next if ! open my $fh, '<', $tmpfile;
- { local $/; $string = <$fh>; }
- close $fh or warn "Could not close $tmpfile\n";
- unlink $tmpfile;
+ next if ! open my $fh, '<', $tmpfile;
+ { local $/; $string = <$fh>; }
+ close $fh or warn "Could not close $tmpfile\n";
+ unlink $tmpfile;
spellcheck("POD from $file" => $string, $file);
}
}
From 761e2602e33c604b5068f24e6bf1d32b1d978ae9 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Fri, 30 Dec 2016 23:14:52 +0100
Subject: [PATCH 085/272] Clarify that only one action is run per invocation.
The old wording could be interpreted as allowing several actions to be
executed in parallel.
Close #115.
---
check_postgres.pl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 76514448..217e0822 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -8721,7 +8721,7 @@ =head1 OTHER OPTIONS
=head1 ACTIONS
-The script runs one or more actions. This can either be done with the --action
+The action to be run is selected using the --action
flag, or by using a symlink to the main file that contains the name of the action
inside of it. For example, to run the action "timesync", you may either issue:
@@ -8732,12 +8732,12 @@ =head1 ACTIONS
check_postgres_timesync
All the symlinks are created for you in the current directory
-if use the option --symlinks
+if use the option --symlinks:
perl check_postgres.pl --symlinks
If the file name already exists, it will not be overwritten. If the file exists
-and is a symlink, you can force it to overwrite by using "--action=build_symlinks_force"
+and is a symlink, you can force it to overwrite by using "--action=build_symlinks_force".
Most actions take a I<--warning> and a I<--critical> option, indicating at what
point we change from OK to WARNING, and what point we go to CRITICAL. Note that
From 580157737dca7c484a7f748641124ffbf6726bd6 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Tue, 10 Jan 2017 10:13:50 -0500
Subject: [PATCH 086/272] Remove carriage returns per bug report from David
Lord on the mailing list
---
check_postgres.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 217e0822..7a09e68d 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2711,6 +2711,9 @@ sub run_command {
}
$db->{ok} = 1;
+ ## Remove carriage returns (i.e. on Win32)
+ $db->{slurp} =~ s/\r//g;
+
## Unfortunately, psql outputs "(No rows)" even with -t and -x
$db->{slurp} = '' if ! defined $db->{slurp} or index($db->{slurp},'(')==0;
@@ -10368,6 +10371,9 @@ =head1 HISTORY
check_hot_standby_delay: Correct extra space in perfdata
(Adrien Nayrat)
+ Remove \r from psql output as it can confuse some regexes
+ (Greg Sabino Mullane)
+
=item B June 30, 2015
Add xact timestamp support to hot_standby_delay.
From 333411c1be2db98ecde2365b82f0f2d2f1eaf4c8 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Tue, 10 Jan 2017 10:15:27 -0500
Subject: [PATCH 087/272] Bump copyright to 2017
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 7a09e68d..4a7020f5 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -11129,7 +11129,7 @@ =head1 NAGIOS EXAMPLES
=head1 LICENSE AND COPYRIGHT
-Copyright (c) 2007-2015 Greg Sabino Mullane .
+Copyright (c) 2007-2017 Greg Sabino Mullane .
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
From fac3154cf8abb5d37f0d456daa0c86d40917fcbe Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 10 Apr 2017 10:06:13 -0500
Subject: [PATCH 088/272] More copyright updates
---
README.md | 2 +-
check_postgres.pl.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index ef7a0811..98d2df15 100644
--- a/README.md
+++ b/README.md
@@ -80,7 +80,7 @@ https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit
COPYRIGHT
---------
- Copyright (c) 2007-2015 Greg Sabino Mullane
+ Copyright (c) 2007-2017 Greg Sabino Mullane
LICENSE INFORMATION
diff --git a/check_postgres.pl.html b/check_postgres.pl.html
index dd7e1c0d..19921b5a 100644
--- a/check_postgres.pl.html
+++ b/check_postgres.pl.html
@@ -2500,7 +2500,7 @@ NAGIOS EXAMPLES
LICENSE AND COPYRIGHT
-Copyright (c) 2007-2015 Greg Sabino Mullane <greg@endpoint.com>.
+Copyright (c) 2007-2017 Greg Sabino Mullane <greg@endpoint.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From 46146df6a25e34893feae5341304e5c0483e1c8f Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 10 Apr 2017 10:06:38 -0500
Subject: [PATCH 089/272] Add explicit LICENSE file
---
LICENSE | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 LICENSE
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..c947a514
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2007-2017 Greg Sabino Mullane
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
From ac1dbf31636348782f6f6268d59a14c1b4b8b912 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Thu, 18 May 2017 09:13:10 -0500
Subject: [PATCH 090/272] Fix possible undefined warning
---
check_postgres.pl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 4a7020f5..7b348465 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2711,12 +2711,12 @@ sub run_command {
}
$db->{ok} = 1;
- ## Remove carriage returns (i.e. on Win32)
- $db->{slurp} =~ s/\r//g;
-
## Unfortunately, psql outputs "(No rows)" even with -t and -x
$db->{slurp} = '' if ! defined $db->{slurp} or index($db->{slurp},'(')==0;
+ ## Remove carriage returns (i.e. on Win32)
+ $db->{slurp} =~ s/\r//g;
+
## Allow an empty query (no matching rows) if requested
if ($arg->{emptyok} and $db->{slurp} =~ /^\s*$/) {
$arg->{emptyok2} = 1;
From 4bbe63e6445364f9cb11bd29da7ec6b8d8d41f6b Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Thu, 18 May 2017 09:57:53 -0500
Subject: [PATCH 091/272] Add very basic Pg10 support in version parsing and
test sanity
---
check_postgres.pl | 2 +-
t/02_backends.t | 2 ++
t/CP_Testing.pm | 4 ++--
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 7b348465..27d4c503 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1641,7 +1641,7 @@ sub msg_en {
}
-x $PSQL or ndie msg('opt-psql-noexec', $PSQL);
$res = qx{$PSQL --version};
-$res =~ /psql\D+(\d+\.\d+)/ or ndie msg('opt-psql-nover');
+$res =~ /psql\D+(\d+(?:\.\d+)?)/ or ndie msg('opt-psql-nover');
our $psql_version = $1;
$VERBOSE >= 2 and warn qq{psql=$PSQL version=$psql_version\n};
diff --git a/t/02_backends.t b/t/02_backends.t
index f369756f..ddbdb11a 100644
--- a/t/02_backends.t
+++ b/t/02_backends.t
@@ -25,9 +25,11 @@ my $label = 'POSTGRES_BACKENDS';
my $ver = $dbh->{pg_server_version};
my $goodver = $ver >= 80200 ? 1 : 0;
my $pg92 = $ver >= 90200 ? 1 : 0;
+my $pg10 = $ver >= 100000 ? 1 : 0;
## Check current number of connections: should be 1 (for recent versions of PG)
$SQL = 'SELECT count(*) FROM pg_stat_activity';
+$SQL .= " WHERE backend_type = 'client backend'" if $pg10;
$count = $dbh->selectall_arrayref($SQL)->[0][0];
$t=q{Current number of backends is one (ourselves)};
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 3ff08789..a9a3d893 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -93,7 +93,7 @@ sub test_database_handle {
: 'initdb';
## Grab the version for finicky items
- if (qx{$initdb --version} !~ /(\d+)\.(\d+)/) {
+ if (qx{$initdb --version} !~ /(\d+)(?:\.(\d+))?/) {
die qq{Could not determine the version of initdb in use!\n};
}
my ($imaj,$imin) = ($1,$2);
@@ -188,7 +188,7 @@ sub test_database_handle {
: $ENV{PGBINDIR} ? "$ENV{PGBINDIR}/pg_ctl"
: 'pg_ctl';
- if (qx{$pg_ctl --version} !~ /(\d+)\.(\d+)/) {
+ if (qx{$pg_ctl --version} !~ /(\d+)(?:\.(\d+))?/) {
die qq{Could not determine the version of pg_ctl in use!\n};
}
my ($maj,$min) = ($1,$2);
From d731c613db8251734a97b77a24c23209dae7ba88 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Fri, 19 May 2017 18:19:34 -0500
Subject: [PATCH 092/272] More PG10 version fixes
---
check_postgres.pl | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 27d4c503..611afaab 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2991,16 +2991,31 @@ sub verify_version {
ndie $info->{db}[0]{error};
}
- if (!defined $info->{db}[0] or $info->{db}[0]{slurp}[0]{setting} !~ /((\d+)\.(\d+))/) {
+ if (!defined $info->{db}[0]) {
ndie msg('die-badversion', $SQL);
}
- my ($sver,$smaj,$smin) = ($1,$2,$3);
+
+ my ($sver,$smaj,$smin);
+
+ if ($info->{db}[0]{slurp}[0]{setting} !~ /((\d+)\.(\d+))/) {
+ # check for Pg10+
+ if ($info->{db}[0]{slurp}[0]{setting} !~ /(1\d+)/) {
+ ndie msg('die-badversion', $SQL);
+ }
+ else {
+ $sver = $smaj = $1;
+ $smin = 0;
+ }
+ }
+ else {
+ ($sver,$smaj,$smin) = ($1,$2,$3);
+ }
if ($versiononly) {
return $sver;
}
- if ($limit =~ /VERSION: ((\d+)\.(\d+))/) {
+ if ($limit =~ /VERSION: ((\d+)(?:\.(\d+))?)/) {
my ($rver,$rmaj,$rmin) = ($1,$2,$3);
if ($smaj < $rmaj or ($smaj==$rmaj and $smin < $rmin)) {
ndie msg('die-action-version', $action, $rver, $sver);
From 23b5a3583ee6d4579dd863c0c7840b08532975d0 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Fri, 19 May 2017 18:23:09 -0500
Subject: [PATCH 093/272] Start building for Pg 10
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 051d535f..a57a6133 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,6 +10,7 @@ env:
- PGVERSION=9.4
- PGVERSION=9.5
- PGVERSION=9.6
+ - PGVERSION=10
# we don't set "language: perl" here because that doesn't use the system perl
From 03bb3908d9e166cd8e077df90f0022f9418161e1 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Fri, 19 May 2017 18:31:56 -0500
Subject: [PATCH 094/272] Fix Pg 10 sources
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index a57a6133..909f7e87 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,9 +17,9 @@ env:
before_install:
# apt.postgresql.org is already configured, we just need to add 9.6
- |
- if [ "$PGVERSION" = "9.6" ]; then
+ if [ "$PGVERSION" = "10" ]; then
# update pgdg-source.list
- sudo sed -i -e 's/main/main 9.6/' /etc/apt/sources.list.d/pgdg*.list
+ sudo sed -i -e 's/main/main 10/' /etc/apt/sources.list.d/pgdg*.list
fi
- sudo apt-get -qq update
From 0ea05215e42792e579c175c17a7248a6ccb45c24 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Sat, 20 May 2017 12:38:33 -0500
Subject: [PATCH 095/272] test using trusty instead of precise to get Pg10
betas
---
.travis.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index 909f7e87..8d7dcfc0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,9 @@ env:
- PGVERSION=9.6
- PGVERSION=10
+dist: trusty
+sudo: required
+
# we don't set "language: perl" here because that doesn't use the system perl
before_install:
From 489290aa460c714efa89a9ab9b40dbd3d033dafa Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Sat, 20 May 2017 13:43:03 -0500
Subject: [PATCH 096/272] Add explicit perls to fix possibly broken trusty env
---
.travis.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index 8d7dcfc0..4a4827b3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,10 @@ env:
dist: trusty
sudo: required
+language: perl
+perl:
+ - 5.10
+ - 5.24
# we don't set "language: perl" here because that doesn't use the system perl
From f1ef69c6d4877574f05324778a1e95783978002a Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Sat, 20 May 2017 13:54:03 -0500
Subject: [PATCH 097/272] Add basic TEST_REQUIRES info for CI
---
Makefile.PL | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makefile.PL b/Makefile.PL
index 82e3948c..00a52616 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -67,6 +67,10 @@ my %opts = (
NEEDS_LINKING => 0,
NORECURS => 1,
PM => {},
+ TEST_REQUIRES => {
+ 'DBD::Pg' => '2.0',
+ 'DBI' => '1.51',
+ },
clean => { FILES => join ' ' => @cleanfiles },
);
From 6e568642ff639f6bb8c1fae345194e51b695afd9 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Sat, 20 May 2017 13:58:00 -0500
Subject: [PATCH 098/272] Move from test dependencies to prereqs
---
Makefile.PL | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 00a52616..ab19b997 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -59,6 +59,8 @@ my %opts = (
'ExtUtils::MakeMaker' => '6.11',
'Test::More' => '0.61',
'version' => '0',
+ 'DBD::Pg' => '2.0',
+ 'DBI' => '1.51',
},
NO_META => 1,
VERSION_FROM => 'check_postgres.pl',
@@ -67,10 +69,6 @@ my %opts = (
NEEDS_LINKING => 0,
NORECURS => 1,
PM => {},
- TEST_REQUIRES => {
- 'DBD::Pg' => '2.0',
- 'DBI' => '1.51',
- },
clean => { FILES => join ' ' => @cleanfiles },
);
From 49d77c62794638a329ade60bab2d9836b745d14f Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Sat, 20 May 2017 14:03:15 -0500
Subject: [PATCH 099/272] add explicit dependency installation step
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 4a4827b3..31e1b0f4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,6 +47,7 @@ install:
script:
- rm -rf test_database_check_postgres*
- perl Makefile.PL
+ - cpanm --quiet --installdeps --notest .
- PGBINDIR=/usr/lib/postgresql/$PGVERSION/bin make test
after_script:
From d74cde4f3ec2008df2920d397ce609cbd492a734 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 22 May 2017 08:54:40 -0500
Subject: [PATCH 100/272] Increase Travis test verbosity for more details about
failures
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 31e1b0f4..ee4bde7e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -48,7 +48,7 @@ script:
- rm -rf test_database_check_postgres*
- perl Makefile.PL
- cpanm --quiet --installdeps --notest .
- - PGBINDIR=/usr/lib/postgresql/$PGVERSION/bin make test
+ - PGBINDIR=/usr/lib/postgresql/$PGVERSION/bin make test TEST_VERBOSE=1
after_script:
- tail -n 200 test_database_check_postgres*/pg.log
From deff580482b73dbaf7ba7227bfcdf1701b6e01e6 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 22 May 2017 09:05:33 -0500
Subject: [PATCH 101/272] Test using TEST_REQUIRES again
---
Makefile.PL | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index ab19b997..024a049a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -56,11 +56,9 @@ my %opts = (
ABSTRACT => 'Postgres monitoring script',
AUTHOR => 'Greg Sabino Mullane ',
PREREQ_PM => {
- 'ExtUtils::MakeMaker' => '6.11',
+ 'ExtUtils::MakeMaker' => '6.64',
'Test::More' => '0.61',
'version' => '0',
- 'DBD::Pg' => '2.0',
- 'DBI' => '1.51',
},
NO_META => 1,
VERSION_FROM => 'check_postgres.pl',
@@ -69,6 +67,11 @@ my %opts = (
NEEDS_LINKING => 0,
NORECURS => 1,
PM => {},
+ TEST_REQUIRES => {
+ 'DBD::Pg' => '2.0',
+ 'DBI' => '1.51',
+ 'Date::Parse' => '0',
+ },
clean => { FILES => join ' ' => @cleanfiles },
);
From 5dabb84b0ebf1098d5b9988f233bf228b431ca5a Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 22 May 2017 09:08:54 -0500
Subject: [PATCH 102/272] Bump skip count on checkpoint test
---
t/02_checkpoint.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/02_checkpoint.t b/t/02_checkpoint.t
index dabee60d..d84de744 100644
--- a/t/02_checkpoint.t
+++ b/t/02_checkpoint.t
@@ -53,7 +53,7 @@ SKIP:
{
if ($result =~ /Date::Parse/) {
- skip 'Cannot test checkpoint action unless Date::Parse module is installed', 6;
+ skip 'Cannot test checkpoint action unless Date::Parse module is installed', 7;
}
like ($cp->run(qq{-w 30 --datadir="$host"}), qr{^$label OK}, $t);
From 5af3b6a03867f9e5be7ee4fac0399d62b9ca992f Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 22 May 2017 16:14:15 -0500
Subject: [PATCH 103/272] No-op change to test with DBD::Pg 3.6.1 bump
---
.travis.yml | 2 +-
check_postgres.pl | 16 ++++++++++++++--
t/02_replication_slots.t | 3 +++
t/02_wal_files.t | 5 +++--
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index ee4bde7e..7d70c3f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ perl:
# we don't set "language: perl" here because that doesn't use the system perl
before_install:
- # apt.postgresql.org is already configured, we just need to add 9.6
+ # apt.postgresql.org is already configured, we just need to add 10
- |
if [ "$PGVERSION" = "10" ]; then
# update pgdg-source.list
diff --git a/check_postgres.pl b/check_postgres.pl
index 611afaab..ddc29556 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -4691,6 +4691,9 @@ sub check_disk_space {
## NOTE: Needs to run on the same system (for now)
## XXX Allow custom ssh commands for remote df and the like
+ my $PG10 = verify_version() >= 10;
+ my $pg_xlog = $PG10 ? 'pg_wal' : 'pg_xlog';
+
my ($warning, $critical) = validate_size_or_percent_with_oper
({
default_warning => '90%',
@@ -4738,7 +4741,7 @@ sub check_disk_space {
$dir{$datadir} = 1;
## Check if the WAL files are on a separate disk
- my $xlog = "$datadir/pg_xlog";
+ my $xlog = "$datadir/$pg_xlog";
if (-l $xlog) {
my $linkdir = readlink($xlog);
$dir{$linkdir} = 1 if ! exists $dir{$linkdir};
@@ -5076,6 +5079,7 @@ sub check_hot_standby_delay {
## --warning='1048576 and 2min' --critical='16777216 and 10min'
my $version = verify_version();
+ my $PG10 = $version >= 10;
my ($warning, $wtime, $critical, $ctime) = validate_integer_for_time({default_to_int => 1});
if ($version < 9.1 and (length $wtime or length $ctime)) {
@@ -5121,6 +5125,7 @@ sub check_hot_standby_delay {
if ($version >= 9.1) {
$SQL .= q{, COALESCE(ROUND(EXTRACT(epoch FROM now() - pg_last_xact_replay_timestamp())),0) AS seconds};
}
+ $SQL =~ s/xlog_location/wal_lsn/g if $PG10;
my $info = run_command($SQL, { dbnumber => $slave, regex => qr/\// });
my $saved_db;
for $db (@{$info->{db}}) {
@@ -5148,6 +5153,7 @@ sub check_hot_standby_delay {
## On master
$SQL = q{SELECT pg_current_xlog_location() AS location};
+ $SQL =~ s/xlog_location/wal_lsn/g if $PG10;
$info = run_command($SQL, { dbnumber => $master });
for $db (@{$info->{db}}) {
my $location = $db->{slurp}[0]{location};
@@ -5225,6 +5231,9 @@ sub check_replication_slots {
## Valid units: b, k, m, g, t, e
## All above may be written as plural or with a trailing 'b'
+ my $version = verify_version();
+ my $PG10 = $version >= 10;
+
my ($warning, $critical) = validate_range({type => 'size'});
$SQL = qq{
@@ -5236,6 +5245,7 @@ sub check_replication_slots {
FROM pg_replication_slots)
SELECT *, pg_size_pretty(delta) AS delta_pretty FROM slots;
};
+ $SQL =~ s/xlog_location/wal_lsn/g if $PG10;
if ($opt{perflimit}) {
$SQL .= " ORDER BY 1 DESC LIMIT $opt{perflimit}";
@@ -8349,6 +8359,8 @@ sub check_wal_files {
## Critical and warning are the number of files
## Example: --critical=40
+ my $pg_xlog = verify_version() >= 10 ? 'pg_wal' : 'pg_xlog';
+
my $subdir = shift || '';
my $extrabit = shift || '';
@@ -8366,7 +8378,7 @@ sub check_wal_files {
my ($warning, $critical) = validate_range($arg);
my $lsfunc = $opt{lsfunc} || 'pg_ls_dir';
- my $lsargs = $opt{lsfunc} ? "" : "'pg_xlog$subdir'";
+ my $lsargs = $opt{lsfunc} ? "" : "'$pg_xlog$subdir'";
## Figure out where the pg_xlog directory is
$SQL = qq{SELECT count(*) AS count FROM $lsfunc($lsargs) WHERE $lsfunc ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars)
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
index 163d836c..14a4f81a 100644
--- a/t/02_replication_slots.t
+++ b/t/02_replication_slots.t
@@ -35,6 +35,9 @@ if ($ver < 90400) {
$t = qq{$S self-identifies correctly};
$result = $cp->run(q{-w 0});
+
+diag($result);
+
like ($result, qr{^$label}, $t);
$t = qq{$S identifies host};
diff --git a/t/02_wal_files.t b/t/02_wal_files.t
index c8e08055..8fe030fd 100644
--- a/t/02_wal_files.t
+++ b/t/02_wal_files.t
@@ -38,6 +38,7 @@ if ($ver < 80100) {
exit;
}
+my $PG10 = $dbh->{pg_server_version} >= 100000;
$t=qq{$S works as expected for warnings};
like ($cp->run('--warning=30'), qr{^$label OK}, $t);
@@ -67,9 +68,9 @@ is ($cp->run('--critical=101 --output=mrtg'), "99\n0\n\n\n", $t);
# test --lsfunc
$dbh->do(q{CREATE FUNCTION ls_xlog_dir()
RETURNS SETOF TEXT
- AS $$ SELECT pg_ls_dir('pg_xlog') $$
+ AS $$ SELECT pg_ls_dir(?) $$
LANGUAGE SQL
- SECURITY DEFINER});
+ SECURITY DEFINER}, undef, $PG10 ? 'pg_wal' : 'pg_xlog' );
$cp->create_fake_pg_table('ls_xlog_dir', ' ');
$dbh->do(q{INSERT INTO cptest.ls_xlog_dir SELECT 'ABCDEF123456ABCDEF123456' FROM generate_series(1,55)});
$dbh->commit();
From e2c6c9ed705f92e43f314cf8f60ab51bc259ad32 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 22 May 2017 16:15:48 -0500
Subject: [PATCH 104/272] Revert "No-op change to test with DBD::Pg 3.6.1 bump"
This reverts commit 5af3b6a03867f9e5be7ee4fac0399d62b9ca992f.
---
.travis.yml | 2 +-
check_postgres.pl | 16 ++--------------
t/02_replication_slots.t | 3 ---
t/02_wal_files.t | 5 ++---
4 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 7d70c3f8..ee4bde7e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ perl:
# we don't set "language: perl" here because that doesn't use the system perl
before_install:
- # apt.postgresql.org is already configured, we just need to add 10
+ # apt.postgresql.org is already configured, we just need to add 9.6
- |
if [ "$PGVERSION" = "10" ]; then
# update pgdg-source.list
diff --git a/check_postgres.pl b/check_postgres.pl
index ddc29556..611afaab 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -4691,9 +4691,6 @@ sub check_disk_space {
## NOTE: Needs to run on the same system (for now)
## XXX Allow custom ssh commands for remote df and the like
- my $PG10 = verify_version() >= 10;
- my $pg_xlog = $PG10 ? 'pg_wal' : 'pg_xlog';
-
my ($warning, $critical) = validate_size_or_percent_with_oper
({
default_warning => '90%',
@@ -4741,7 +4738,7 @@ sub check_disk_space {
$dir{$datadir} = 1;
## Check if the WAL files are on a separate disk
- my $xlog = "$datadir/$pg_xlog";
+ my $xlog = "$datadir/pg_xlog";
if (-l $xlog) {
my $linkdir = readlink($xlog);
$dir{$linkdir} = 1 if ! exists $dir{$linkdir};
@@ -5079,7 +5076,6 @@ sub check_hot_standby_delay {
## --warning='1048576 and 2min' --critical='16777216 and 10min'
my $version = verify_version();
- my $PG10 = $version >= 10;
my ($warning, $wtime, $critical, $ctime) = validate_integer_for_time({default_to_int => 1});
if ($version < 9.1 and (length $wtime or length $ctime)) {
@@ -5125,7 +5121,6 @@ sub check_hot_standby_delay {
if ($version >= 9.1) {
$SQL .= q{, COALESCE(ROUND(EXTRACT(epoch FROM now() - pg_last_xact_replay_timestamp())),0) AS seconds};
}
- $SQL =~ s/xlog_location/wal_lsn/g if $PG10;
my $info = run_command($SQL, { dbnumber => $slave, regex => qr/\// });
my $saved_db;
for $db (@{$info->{db}}) {
@@ -5153,7 +5148,6 @@ sub check_hot_standby_delay {
## On master
$SQL = q{SELECT pg_current_xlog_location() AS location};
- $SQL =~ s/xlog_location/wal_lsn/g if $PG10;
$info = run_command($SQL, { dbnumber => $master });
for $db (@{$info->{db}}) {
my $location = $db->{slurp}[0]{location};
@@ -5231,9 +5225,6 @@ sub check_replication_slots {
## Valid units: b, k, m, g, t, e
## All above may be written as plural or with a trailing 'b'
- my $version = verify_version();
- my $PG10 = $version >= 10;
-
my ($warning, $critical) = validate_range({type => 'size'});
$SQL = qq{
@@ -5245,7 +5236,6 @@ sub check_replication_slots {
FROM pg_replication_slots)
SELECT *, pg_size_pretty(delta) AS delta_pretty FROM slots;
};
- $SQL =~ s/xlog_location/wal_lsn/g if $PG10;
if ($opt{perflimit}) {
$SQL .= " ORDER BY 1 DESC LIMIT $opt{perflimit}";
@@ -8359,8 +8349,6 @@ sub check_wal_files {
## Critical and warning are the number of files
## Example: --critical=40
- my $pg_xlog = verify_version() >= 10 ? 'pg_wal' : 'pg_xlog';
-
my $subdir = shift || '';
my $extrabit = shift || '';
@@ -8378,7 +8366,7 @@ sub check_wal_files {
my ($warning, $critical) = validate_range($arg);
my $lsfunc = $opt{lsfunc} || 'pg_ls_dir';
- my $lsargs = $opt{lsfunc} ? "" : "'$pg_xlog$subdir'";
+ my $lsargs = $opt{lsfunc} ? "" : "'pg_xlog$subdir'";
## Figure out where the pg_xlog directory is
$SQL = qq{SELECT count(*) AS count FROM $lsfunc($lsargs) WHERE $lsfunc ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars)
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
index 14a4f81a..163d836c 100644
--- a/t/02_replication_slots.t
+++ b/t/02_replication_slots.t
@@ -35,9 +35,6 @@ if ($ver < 90400) {
$t = qq{$S self-identifies correctly};
$result = $cp->run(q{-w 0});
-
-diag($result);
-
like ($result, qr{^$label}, $t);
$t = qq{$S identifies host};
diff --git a/t/02_wal_files.t b/t/02_wal_files.t
index 8fe030fd..c8e08055 100644
--- a/t/02_wal_files.t
+++ b/t/02_wal_files.t
@@ -38,7 +38,6 @@ if ($ver < 80100) {
exit;
}
-my $PG10 = $dbh->{pg_server_version} >= 100000;
$t=qq{$S works as expected for warnings};
like ($cp->run('--warning=30'), qr{^$label OK}, $t);
@@ -68,9 +67,9 @@ is ($cp->run('--critical=101 --output=mrtg'), "99\n0\n\n\n", $t);
# test --lsfunc
$dbh->do(q{CREATE FUNCTION ls_xlog_dir()
RETURNS SETOF TEXT
- AS $$ SELECT pg_ls_dir(?) $$
+ AS $$ SELECT pg_ls_dir('pg_xlog') $$
LANGUAGE SQL
- SECURITY DEFINER}, undef, $PG10 ? 'pg_wal' : 'pg_xlog' );
+ SECURITY DEFINER});
$cp->create_fake_pg_table('ls_xlog_dir', ' ');
$dbh->do(q{INSERT INTO cptest.ls_xlog_dir SELECT 'ABCDEF123456ABCDEF123456' FROM generate_series(1,55)});
$dbh->commit();
From 97cd6dc16f9f5c44ca1e3c39d69492261bb4c3cb Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 22 May 2017 16:17:14 -0500
Subject: [PATCH 105/272] Remove libdbd-pg-perl installation; use cpanm for
installing dep to pick up latest 3.6.1
---
.travis.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index ee4bde7e..0ffdc5bb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ perl:
# we don't set "language: perl" here because that doesn't use the system perl
before_install:
- # apt.postgresql.org is already configured, we just need to add 9.6
+ # apt.postgresql.org is already configured, we just need to add 10
- |
if [ "$PGVERSION" = "10" ]; then
# update pgdg-source.list
@@ -31,7 +31,6 @@ before_install:
- sudo apt-get -qq update
install:
- - sudo apt-get install libdbd-pg-perl
# install PostgreSQL $PGVERSION if not there yet
- |
if [ ! -x /usr/lib/postgresql/$PGVERSION/bin/postgres ]; then
From 91edef9f7bf447ea375d385360a17e96195f2317 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 22 May 2017 16:23:31 -0500
Subject: [PATCH 106/272] Reverse version sorting to prioritize Pg10 in testing
The other versions are just there for regression testing, so deprioritize those
---
.travis.yml | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 0ffdc5bb..59484ae4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,15 +2,15 @@
---
# versions to run on
env:
- - PGVERSION=8.4
- - PGVERSION=9.0
- - PGVERSION=9.1
- - PGVERSION=9.2
- - PGVERSION=9.3
- - PGVERSION=9.4
- - PGVERSION=9.5
- - PGVERSION=9.6
- PGVERSION=10
+ - PGVERSION=9.6
+ - PGVERSION=9.5
+ - PGVERSION=9.4
+ - PGVERSION=9.3
+ - PGVERSION=9.2
+ - PGVERSION=9.1
+ - PGVERSION=9.0
+ - PGVERSION=8.4
dist: trusty
sudo: required
From 8b60d0475d76c16a062b15ceccc743b3f497323f Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Mon, 10 Jul 2017 16:59:28 +0200
Subject: [PATCH 107/272] Document that the testsuite needs a clean environment
Suggest using `env -i` for running the testsuite.
---
README.dev | 5 +++++
README.md | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/README.dev b/README.dev
index 744cf849..8060b9d9 100644
--- a/README.dev
+++ b/README.dev
@@ -8,11 +8,16 @@ For testing PostgreSQL 9.2 and later, DBD::Pg 2.19.3 is required.
Running the testsuite:
+* env -i make test
* LC_ALL=C make test
* initdb and friends not in $PATH: LC_ALL=C make test PGBINDIR=/usr/lib/postgresql/9.2/bin
* Run a single test: LC_ALL=C make test TEST_FILES=t/02_database_size.t
* Skip network tests: LC_ALL=C make test SKIP_NETWORK_TESTS=1
+The testsuite is sensitive to locale and PG environment variables such as LANG
+and PGDATABASE. Using `env -i` will unset all variables from the user
+environment for running the tests.
+
** RELEASE PROCESS **
Quick notes on the current release process:
diff --git a/README.md b/README.md
index 98d2df15..481a21dc 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ The better way to install this script is via the standard Perl process:
perl Makefile.PL
make
- make test
+ env -i make test
make install
The last step usually needs to be done as the root user. You may want to
@@ -44,7 +44,8 @@ for that purpose. See the "Quick" instructions above.
For `make test`, please report any failing tests to check_postgres@bucardo.org.
The tests need to have some standard Postgres binaries available, such as
`initdb`, `psql`, and `pg_ctl`. If these are not in your path, or you want to
-use specific ones, please set the environment variable `PGBINDIR` first.
+use specific ones, please set the environment variable `PGBINDIR` first. More
+details on running the testsuite are available in `README.dev`.
Once `make install` has been done, you should have access to the complete
documentation by typing:
From 10831112f39a298c9955c0dcdf65e5164baacfa5 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Mon, 10 Jul 2017 17:18:41 +0200
Subject: [PATCH 108/272] Quote perl version so they don't get parsed as floats
("Perl 5.1")
---
.travis.yml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 59484ae4..743a5fe8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,10 +16,8 @@ dist: trusty
sudo: required
language: perl
perl:
- - 5.10
- - 5.24
-
-# we don't set "language: perl" here because that doesn't use the system perl
+ - '5.10'
+ - '5.24'
before_install:
# apt.postgresql.org is already configured, we just need to add 10
From 1ceed172ca2effd8d192940d1c8ecafde1016cc8 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Mon, 10 Jul 2017 17:53:47 +0200
Subject: [PATCH 109/272] Relax version checking regexps to catch PG 10 better
---
check_postgres.pl | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 611afaab..c893d85b 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2059,11 +2059,11 @@ sub finishup {
my $limit = $testaction{lc $ac};
next if ! defined $limit;
- if ($limit =~ /VERSION: ((\d+)\.(\d+))/) {
+ if ($limit =~ /VERSION: ((\d+)\.?(\d+))/) {
my ($rver,$rmaj,$rmin) = ($1,$2,$3);
for my $db (@{$info->{db}}) {
next unless exists $db->{ok};
- if ($set{server_version} !~ /((\d+)\.(\d+))/) {
+ if ($set{server_version} !~ /((\d+)\.?(\d+))/) {
print msgn('testmode-nover', $db->{pname});
next;
}
@@ -2079,7 +2079,7 @@ sub finishup {
my ($rver,$rmaj,$rmin) = ($1,$2,$3);
for my $db (@{$info->{db}}) {
next unless exists $db->{ok};
- if ($set{server_version} !~ /((\d+)\.(\d+))/) {
+ if ($set{server_version} !~ /((\d+)\.?(\d+))/) {
print msgn('testmode-nover', $db->{pname});
next;
}
@@ -2603,7 +2603,7 @@ sub run_command {
else {
$string = $arg->{oldstring} || $arg->{string};
for my $row (@{$arg->{version}}) {
- if ($row !~ s/^([<>]?)(\d+\.\d+)\s+//) {
+ if ($row !~ s/^([<>]?)(\d+\.?\d+)\s+//) {
ndie msg('die-badversion', $row);
}
my ($mod,$ver) = ($1||'',$2);
@@ -2726,7 +2726,7 @@ sub run_command {
if ($db->{error}) {
ndie $db->{error};
}
- if ($db->{slurp} !~ /(\d+\.\d+)/) {
+ if ($db->{slurp} !~ /(\d+\.?\d+)/) {
ndie msg('die-badversion', $db->{slurp});
}
$db->{version} = $1;
@@ -2997,18 +2997,11 @@ sub verify_version {
my ($sver,$smaj,$smin);
- if ($info->{db}[0]{slurp}[0]{setting} !~ /((\d+)\.(\d+))/) {
- # check for Pg10+
- if ($info->{db}[0]{slurp}[0]{setting} !~ /(1\d+)/) {
- ndie msg('die-badversion', $SQL);
- }
- else {
- $sver = $smaj = $1;
- $smin = 0;
- }
+ if ($info->{db}[0]{slurp}[0]{setting} !~ /^((\d+)(\.(:?\d+))?)/) {
+ ndie msg('die-badversion', $SQL);
}
else {
- ($sver,$smaj,$smin) = ($1,$2,$3);
+ ($sver,$smaj,$smin) = ($1,$2,$3||0);
}
if ($versiononly) {
@@ -3200,10 +3193,10 @@ sub validate_range {
}
elsif ('version' eq $type) {
my $msg = msg('range-version');
- if (length $warning and $warning !~ /^\d+\.\d+\.?[\d\w]*$/) {
+ if (length $warning and $warning !~ /^\d+\.?\d+\.?[\d\w]*$/) {
ndie msg('range-badversion', 'warning', $msg);
}
- if (length $critical and $critical !~ /^\d+\.\d+\.?[\d\w]*$/) {
+ if (length $critical and $critical !~ /^\d+\.?\d+\.?[\d\w]*$/) {
ndie msg('range-badversion', 'critical', $msg);
}
if (! length $critical and ! length $warning) {
@@ -8286,10 +8279,10 @@ sub check_version {
## or the major, minor, and revision (e.g. 8.2.4 or even 8.3beta4)
if ($MRTG) {
- if (!exists $opt{mrtg} or $opt{mrtg} !~ /^\d+\.\d+/) {
+ if (!exists $opt{mrtg} or $opt{mrtg} !~ /^\d+\.?\d+/) {
ndie msg('version-badmrtg');
}
- if ($opt{mrtg} =~ /^\d+\.\d+$/) {
+ if ($opt{mrtg} =~ /^\d+\.?\d+$/) {
$opt{critical} = $opt{mrtg};
}
else {
@@ -8299,13 +8292,13 @@ sub check_version {
my ($warning, $critical) = validate_range({type => 'version', forcemrtg => 1});
- my ($warnfull, $critfull) = (($warning =~ /^\d+\.\d+$/ ? 0 : 1),($critical =~ /^\d+\.\d+$/ ? 0 : 1));
+ my ($warnfull, $critfull) = (($warning =~ /^\d+\.?\d+$/ ? 0 : 1),($critical =~ /^\d+\.?\d+$/ ? 0 : 1));
my $info = run_command('SELECT version() AS version');
for $db (@{$info->{db}}) {
my $row = $db->{slurp}[0];
- if ($row->{version} !~ /((\d+\.\d+)(\w+|\.\d+))/) {
+ if ($row->{version} !~ /((\d+\.?\d+)(\w+|\.\d+))/) {
add_unknown msg('invalid-query', $row->{version});
next;
}
From 9660e00ba18f485d2ad5d2dd0203f128689cfbee Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 11 Jul 2017 10:33:49 +0200
Subject: [PATCH 110/272] Sort failed jobs in check_pgagent_jobs for stable
output
Also, append a space to test regexps to make sure the output really ends
there (otherwise, there would be a ';') and fix a testcase where this
was wrong.
---
check_postgres.pl | 6 ++++++
t/02_pgagent_jobs.t | 34 +++++++++++++++++-----------------
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index c893d85b..08beb91c 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -5972,6 +5972,7 @@ sub check_pgagent_jobs {
JOIN pgagent.pga_jobsteplog slog ON jlog.jlgid = slog.jsljlgid AND step.jstid = slog.jsljstid
WHERE ((slog.jslresult = -1 AND step.jstkind='s') OR (slog.jslresult <> 0 AND step.jstkind='b'))
AND EXTRACT('epoch' FROM NOW() - (jlog.jlgstart + jlog.jlgduration)) < $seconds
+ ORDER BY jlog.jlgstart DESC
};
my $info = run_command($SQL);
@@ -10344,12 +10345,14 @@ =head1 HISTORY
total_relation_size, using the respective pg_indexes_size() and
pg_total_relation_size() functions. All size checks will now also check
materialized views where applicable.
+ (Christoph Berg)
Connection errors are now always critical, not unknown.
(Christoph Berg)
New action replication_slots checking if logical or physical replication
slots have accumulated too much data
+ (Glyn Astill)
Multiple same_schema improvements
(Glyn Astill)
@@ -10382,6 +10385,9 @@ =head1 HISTORY
Remove \r from psql output as it can confuse some regexes
(Greg Sabino Mullane)
+ Sort failed jobs in check_pgagent_jobs for stable output.
+ (Christoph Berg)
+
=item B June 30, 2015
Add xact timestamp support to hot_standby_delay.
diff --git a/t/02_pgagent_jobs.t b/t/02_pgagent_jobs.t
index 26f51826..fff46590 100644
--- a/t/02_pgagent_jobs.t
+++ b/t/02_pgagent_jobs.t
@@ -124,14 +124,14 @@ like $cp->run('-c=2h'), qr{^$label OK: DB "postgres"},
"$S -c=2h returns ok with failed job before our time";
like $cp->run('-c=6h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -c=6h returns critical with failed job within our time";
like $cp->run('-w=2h'), qr{^$label OK: DB "postgres"},
"$S -w=2h returns ok with failed job before our time";
like $cp->run('-w=6h'),
- qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=6h returns warninf with failed job within our time";
like $cp->run('-w=2h'), qr{^$label OK: DB "postgres"},
@@ -141,15 +141,15 @@ like $cp->run('-w=4h -c=2h'), qr{^$label OK: DB "postgres"},
"$S -w=4h =c=2h returns ok with failed job before our time";
like $cp->run('-w=5h -c=2h'),
- qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=5h =c=2h returns warning with failed job within our time";
like $cp->run('-w=2h -c=5h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=2h =c=5h returns critical with failed job within our time";
like $cp->run('-w=5h -c=5h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=5h =c=5h returns critical with failed job within our time";
# Make a second job fail, back 30 hours.
@@ -165,14 +165,14 @@ like $cp->run('-c=2h'), qr{^$label OK: DB "postgres"},
"$S -c=2h returns ok with failed job before our time";
like $cp->run('-c=6h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -c=6h returns critical with failed job within our time";
like $cp->run('-w=2h'), qr{^$label OK: DB "postgres"},
"$S -w=2h returns ok with failed job before our time";
like $cp->run('-w=6h'),
- qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=6h returns warninf with failed job within our time";
like $cp->run('-w=2h'), qr{^$label OK: DB "postgres"},
@@ -182,42 +182,42 @@ like $cp->run('-w=4h -c=2h'), qr{^$label OK: DB "postgres"},
"$S -w=4h =c=2h returns ok with failed job before our time";
like $cp->run('-w=5h -c=2h'),
- qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=5h =c=2h returns warning with failed job within our time";
like $cp->run('-w=2h -c=5h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=2h =c=5h returns critical with failed job within our time";
like $cp->run('-w=5h -c=5h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF! },
"$S -w=5h -c=5h returns critical with failed job within our time";
# Go back further in time!
like $cp->run('-w=30h -c=2h'),
- qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!},
- "$S -w=30h -c=5h returns warning for older failed job";
+ qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL! },
+ "$S -w=30h -c=2h returns warning for older failed job";
like $cp->run('-w=30h -c=6h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL! },
"$S -w=30h -c=6h returns critical with both jobs, more recent critical";
like $cp->run('-c=30h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL! },
"$S -c=30h returns critical with both failed jobs";
like $cp->run('-w=30h'),
- qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL!},
+ qr{^$label WARNING: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL! },
"$S -w=30h returns critical with both failed jobs";
# Try with critical recent and warning longer ago.
like $cp->run('-w=30h -c=6h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL! },
"$S -w=30h -c=6h returns critical with both failed jobs";
# Try with warning recent and critical longer ago.
like $cp->run('-c=30h -w=6h'),
- qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL!},
+ qr{^$label CRITICAL: DB "postgres" [()][^)]+[)] 255 Restore/analyze: WTF!; 64 Restore/analyze: OMGWTFLOL! },
"$S -c=30h -w=6h returns critical with both failed jobs";
# Undo the more recent failure.
From 049fdc12318498e46a6ab659d3c618f8b10a7822 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 11 Jul 2017 10:42:19 +0200
Subject: [PATCH 111/272] check_replication_slots: Support PostgreSQL 10
---
check_postgres.pl | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 08beb91c..20c24cb9 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -5233,8 +5233,10 @@ sub check_replication_slots {
if ($opt{perflimit}) {
$SQL .= " ORDER BY 1 DESC LIMIT $opt{perflimit}";
}
+ my $SQL10;
+ ($SQL10 = $SQL) =~ s/xlog_location/wal_lsn/g;
- my $info = run_command($SQL, { regex => qr{\d+}, emptyok => 1, } );
+ my $info = run_command($SQL, { regex => qr{\d+}, emptyok => 1, version => [">9.6 $SQL10"] } );
my $found = 0;
for $db (@{$info->{db}}) {
@@ -10340,6 +10342,9 @@ =head1 HISTORY
=item B Released ????
+ Support PostgreSQL 10.
+ (David Christensen, Christoph Berg)
+
Change table_size to use pg_table_size() on 9.0+, i.e. include the TOAST
table size in the numbers reported. Add new actions indexes_size and
total_relation_size, using the respective pg_indexes_size() and
From 3776243599326cb0031fcda248a6ed6c9d68a4c9 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 11 Jul 2017 11:27:55 +0200
Subject: [PATCH 112/272] Fix sequences in same_schema for PostgreSQL 10
pg_sequences is now the same that was SELECT * FROM sequence1...2...3
before, except that last_value is NULL for not-yet-called sequences
---
check_postgres.pl | 7 ++++++-
t/02_same_schema.t | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 20c24cb9..e565e71e 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1024,6 +1024,7 @@ package check_postgres;
JOIN pg_namespace n ON (n.oid = c.relnamespace)
WHERE c.relkind = 'S'},
innerSQL => 'SELECT * FROM ROWSAFENAME',
+ SQL10 => q{SELECT schemaname||'.'||sequencename AS name, * FROM pg_sequences},
},
view => {
SQL => q{
@@ -6743,7 +6744,7 @@ sub check_same_schema {
my $foo = $info->{db}[0];
my $version = $foo->{slurp}[0]{version};
- $version =~ /\D+(\d+\.\d+)(\S+)/i or die qq{Invalid version: $version\n};
+ $version =~ /\D+(\d+\.?\d+)(\S+)/i or die qq{Invalid version: $version\n};
my ($full,$major,$revision) = ("$1$2",$1,$2);
$revision =~ s/^\.//;
$dbver{$num} = {
@@ -7498,6 +7499,10 @@ sub find_catalog_info {
if ($type eq 'trigger' and $dbver->{major} <= 8.4) {
$SQL =~ s/t.tgconstrindid = 0 AND //;
}
+ if ($type eq 'sequence' and $dbver->{major} >= 10) {
+ $SQL = $ci->{SQL10};
+ delete $ci->{innerSQL};
+ }
if (exists $ci->{exclude}) {
if ('temp_schemas' eq $ci->{exclude}) {
diff --git a/t/02_same_schema.t b/t/02_same_schema.t
index ed31071d..3b755871 100644
--- a/t/02_same_schema.t
+++ b/t/02_same_schema.t
@@ -340,6 +340,8 @@ Sequence "wakko.yakko" does not exist on all databases:
$t = qq{$S reports sequence differences};
$dbh2->do(q{CREATE SEQUENCE wakko.yakko MINVALUE 10 MAXVALUE 100 INCREMENT BY 3});
+$dbh1->do(q{SELECT nextval('wakko.yakko')});
+$dbh2->do(q{SELECT nextval('wakko.yakko')});
like ($cp1->run($connect2),
qr{^$label CRITICAL.*Items not matched: 1 .*
From 78cd1e863422f47d05a9579045ef60bab1416a89 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 11 Jul 2017 12:41:07 +0200
Subject: [PATCH 113/272] Fix schema action for PG10
Unfortunately the data collection and output producing parts are tightly
intertwingled. For now, I've just hacked the PG10 query into that
structure, but the loop-over-all-sequences part should really be
refactored.
---
check_postgres.pl | 14 +++++++++++++-
t/02_sequence.t | 2 ++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index e565e71e..b181cb90 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -7686,9 +7686,17 @@ sub check_sequence {
WHERE nspname !~ '^pg_temp.*'
ORDER BY nspname, seqname, typname
};
+ my $SQL10 = q{
+SELECT seqname, last_value, slots, used, ROUND(used/slots*100) AS percent,
+ CASE WHEN slots < used THEN 0 ELSE slots - used END AS numleft
+FROM (
+ SELECT quote_ident(schemaname)||'.'||quote_ident(sequencename) AS seqname, COALESCE(last_value,min_value) AS last_value,
+ CEIL((max_value-min_value::numeric+1)/increment_by::NUMERIC) AS slots,
+ CEIL((COALESCE(last_value,min_value)-min_value::numeric+1)/increment_by::NUMERIC) AS used
+FROM pg_sequences) foo};
## use critic
- my $info = run_command($SQL, {regex => qr{\w}, emptyok => 1} );
+ my $info = run_command($SQL, {regex => qr{\w}, emptyok => 1, version => [">9.6 SELECT 1"]} ); # actual SQL10 is executed below
my $MAXINT2 = 32767;
my $MAXINT4 = 2147483647;
@@ -7704,6 +7712,7 @@ sub check_sequence {
my $multidb = @{$info->{db}} > 1 ? "$db->{dbname}." : '';
my @seq_sql;
for my $r (@{$db->{slurp}}) { # for each sequence, create SQL command to inspect it
+ next if ($db->{version} >= 10); # TODO: skip loop entirely
my ($schema, $seq, $seqname, $typename) = @$r{qw/ nspname seqname safename typname /};
next if skip_item($seq);
my $maxValue = $typename eq 'int2' ? $MAXINT2 : $typename eq 'int4' ? $MAXINT4 : $MAXINT8;
@@ -7719,6 +7728,9 @@ sub check_sequence {
FROM $seqname) foo
};
}
+ if ($db->{version} >= 10) {
+ @seq_sql = ($SQL10); # inject PG10 query here (TODO: pull this out of loops)
+ }
# Use UNION ALL to query multiple sequences at once, however if there are too many sequences this can exceed
# maximum argument length; so split into chunks of 200 sequences or less and iterate over them.
while (my @seq_sql_chunk = splice @seq_sql, 0, 200) {
diff --git a/t/02_sequence.t b/t/02_sequence.t
index 1111d895..9403fd27 100644
--- a/t/02_sequence.t
+++ b/t/02_sequence.t
@@ -81,6 +81,8 @@ like ($cp->run('--critical=10%'), qr{CRITICAL:.+public.cp_test_sequence=11% \(ca
$t=qq{$S returns correct information for a sequence with custom increment};
$dbh->do("ALTER SEQUENCE $seqname INCREMENT 10 MAXVALUE 90 RESTART WITH 25");
+$dbh->do("SELECT nextval('$seqname')"); # otherwise 25 isn't visible on PG10+
+$dbh->commit();
like ($cp->run('--critical=22%'), qr{CRITICAL:.+public.cp_test_sequence=33% \(calls left=6\)}, $t);
$t=qq{$S returns correct information with MRTG output};
From 71a9422f4ef70f020aa574a9169130a859253d26 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 11 Jul 2017 13:10:08 +0200
Subject: [PATCH 114/272] Fix txn_idle for PG10
pg_stat_activity.query might be '', don't treat that as missing
---
check_postgres.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index b181cb90..7e8d8e99 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -8090,8 +8090,8 @@ sub check_txn_idle {
next if skip_item($r->{datname});
## We do a lot of filtering based on the current_query or state in 9.2+
- my $cq = $r->{query} || $r->{current_query};
- my $st = $r->{state} || '';
+ my $cq = $r->{query} // $r->{current_query};
+ my $st = $r->{state} // '';
## Return unknown if we cannot see because we are a non-superuser
if ($cq =~ /insufficient/) {
From a314b4576507550f47ef9476d3a4612eb3f24c28 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 11 Jul 2017 13:34:06 +0200
Subject: [PATCH 115/272] Fix wal files checks for PG10
---
check_postgres.pl | 10 ++++++----
t/02_wal_files.t | 6 ++++--
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 7e8d8e99..941a3f28 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -8383,8 +8383,10 @@ sub check_wal_files {
## Figure out where the pg_xlog directory is
$SQL = qq{SELECT count(*) AS count FROM $lsfunc($lsargs) WHERE $lsfunc ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars)
+ my $SQL10 = $SQL;
+ $SQL10 =~ s/pg_xlog/pg_wal/g unless ($opt{lsfunc});
- my $info = run_command($SQL, {regex => qr[\d] });
+ my $info = run_command($SQL, {regex => qr[\d], version => [">9.6 $SQL10"] });
my $found = 0;
for $db (@{$info->{db}}) {
@@ -8780,7 +8782,7 @@ =head1 ACTIONS
=head2 B
(C) Checks how many WAL files with extension F<.ready>
-exist in the F directory, which is found
+exist in the F directory (PostgreSQL 10 and later: F), which is found
off of your B. If the I<--lsfunc> option is not used then this action must be run as a superuser, in order to access the
contents of the F directory. The minimum version to use this action is
Postgres 8.1. The I<--warning> and I<--critical> options are simply the number of
@@ -9230,7 +9232,7 @@ =head2 B
B - The disk that the log files are on.
-B - The disk that the write-ahead logs are on (e.g. symlinked pg_xlog)
+B - The disk that the write-ahead logs are on (e.g. symlinked pg_xlog or pg_wal)
B - Each tablespace that is on a separate disk.
@@ -10116,7 +10118,7 @@ =head2 B
=head2 B
-(C) Checks how many WAL files exist in the F directory, which is found
+(C) Checks how many WAL files exist in the F directory (PostgreSQL 10 and later" F), which is found
off of your B, sometimes as a symlink to another physical disk for
performance reasons. If the I<--lsfunc> option is not used then this action must be run as a superuser, in order to access the
contents of the F directory. The minimum version to use this action is
diff --git a/t/02_wal_files.t b/t/02_wal_files.t
index c8e08055..d3d210b7 100644
--- a/t/02_wal_files.t
+++ b/t/02_wal_files.t
@@ -49,6 +49,7 @@ like ($cp->run('--critical=1'), qr{^$label CRITICAL}, $t);
$cp->drop_schema_if_exists();
$cp->create_fake_pg_table('pg_ls_dir', 'text');
+$dbh->commit();
like ($cp->run('--critical=1'), qr{^$label OK}, $t);
@@ -65,9 +66,10 @@ $t=qq{$S returns correct MRTG information};
is ($cp->run('--critical=101 --output=mrtg'), "99\n0\n\n\n", $t);
# test --lsfunc
-$dbh->do(q{CREATE FUNCTION ls_xlog_dir()
+my $xlogdir = $ver >= 100000 ? 'pg_wal' : 'pg_xlog';
+$dbh->do(qq{CREATE FUNCTION ls_xlog_dir()
RETURNS SETOF TEXT
- AS $$ SELECT pg_ls_dir('pg_xlog') $$
+ AS \$\$ SELECT pg_ls_dir('$xlogdir') \$\$
LANGUAGE SQL
SECURITY DEFINER});
$cp->create_fake_pg_table('ls_xlog_dir', ' ');
From d9533a3fc50e1270ecc8f94be35e4da31eed1e33 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 11 Jul 2017 13:56:40 +0200
Subject: [PATCH 116/272] Add travis badge
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 481a21dc..437e9cd9 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
check_postgres
==============
+[](https://travis-ci.org/bucardo/check_postgres)
+
This is check_postgres, a monitoring tool for Postgres.
The most complete and up to date information about this script can be found at:
From 651e1e6ff3b9661c42900d7728c4e8d071601dd1 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Thu, 31 Aug 2017 15:46:45 -0400
Subject: [PATCH 117/272] Add TODO item about privs for actions
---
TODO | 2 ++
1 file changed, 2 insertions(+)
diff --git a/TODO b/TODO
index bd0e61c0..ac5b900c 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,8 @@ Quick list of outstanding items / bugs / feature requests for CP:
NOTE: All bugzilla items are now on github
+* Add documentation on privs required for each action, and recommended grants for roles, etc.
+
* The same_schema action does not check indexes. See bugzilla #54
* Perform automatic creation of views and function to allow all actions to be run
From f946cffc32c5d444bedefe120f15fc4740881a8b Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Thu, 7 Sep 2017 12:11:38 -0500
Subject: [PATCH 118/272] Provide Pg 10 superuser avoidance advice for txn_idle
---
check_postgres.pl | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 941a3f28..06b270e2 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -10028,9 +10028,10 @@ =head2 B
This action requires Postgres 8.3 or better.
-Superuser privileges are required to see the queries of all users in the system;
-UNKNOWN is returned if queries cannot be checked. To only include queries by
-the connecting user, use I<--includeuser>.
+As of PostgreSQL 10, you can just GRANT I to an unprivileged user account. In
+all earlier versions, superuser privileges are required to see the queries of all users in the
+system; UNKNOWN is returned if queries cannot be checked. To only include queries by the connecting
+user, use I<--includeuser>.
Example 1: Give a warning if any connection has been idle in transaction for more than 15 seconds:
From efb1b311aaad8b3724557e4aace059f4cca34134 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Sat, 9 Sep 2017 19:39:21 -0400
Subject: [PATCH 119/272] Skip tests until we have a plugin
---
t/02_replication_slots.t | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
index 163d836c..22ad1b36 100644
--- a/t/02_replication_slots.t
+++ b/t/02_replication_slots.t
@@ -75,6 +75,10 @@ like ($result, qr{^$label OK:}, $t);
$dbh->do ("SELECT pg_drop_replication_slot('cp_testing_slot')");
+SKIP: {
+
+ skip qq{Waiting for test_decoding plugin};
+
# To do more tests on physical slots we'd actually have to kick off some activity by performing a connection to them (.. use pg_receivexlog or similar??)
$dbh->do ("SELECT * FROM pg_create_logical_replication_slot('cp_testing_slot', 'test_decoding')");
@@ -93,7 +97,6 @@ like ($result, qr{^$label OK:}, $t);
$dbh->do ("CREATE TABLE cp_testing_table (a text); INSERT INTO cp_testing_table SELECT a || repeat('A',1024) FROM generate_series(1,1024) a; DROP TABLE cp_testing_table;");
-
$t=qq{$S reports warning on logical replication slots when warning level is specified and is exceeded};
$result = $cp->run(q{-w 1MB});
like ($result, qr{^$label WARNING:}, $t);
@@ -124,4 +127,6 @@ like ($result, qr{^$label UNKNOWN:.*No matching replication slots}, $t);
$dbh->do ("SELECT pg_drop_replication_slot('cp_testing_slot')");
+}
+
exit;
From 72085b58d4267286af7bcf2134a5dbb0635820c3 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Sat, 9 Sep 2017 19:48:34 -0400
Subject: [PATCH 120/272] Version 2.23.0
---
META.yml | 4 ++--
Makefile.PL | 2 +-
check_postgres.pl | 6 +++---
check_postgres.pl.html | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/META.yml b/META.yml
index 09bb4d40..181b552b 100644
--- a/META.yml
+++ b/META.yml
@@ -1,6 +1,6 @@
--- #YAML:1.0
name : check_postgres.pl
-version : 2.22.0
+version : 2.23.0
abstract : Postgres monitoring script
author:
- Greg Sabino Mullane
@@ -30,7 +30,7 @@ recommends:
provides:
check_postgres:
file : check_postgres.pl
- version : 2.22.0
+ version : 2.23.0
keywords:
- Postgres
diff --git a/Makefile.PL b/Makefile.PL
index 024a049a..80ce7e8d 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -6,7 +6,7 @@ use strict;
use warnings;
use 5.006001;
-my $VERSION = '2.22.0';
+my $VERSION = '2.23.0';
if ($VERSION =~ /_/) {
print "WARNING! This is a test version ($VERSION) and should not be used in production!\n";
diff --git a/check_postgres.pl b/check_postgres.pl
index 06b270e2..bc310809 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -33,7 +33,7 @@ package check_postgres;
binmode STDOUT, ':encoding(UTF-8)';
-our $VERSION = '2.22.1';
+our $VERSION = '2.23.0';
use vars qw/ %opt $PGBINDIR $PSQL $res $COM $SQL $db /;
@@ -8422,7 +8422,7 @@ =head1 NAME
B - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.22.1
+This documents describes check_postgres.pl version 2.23.0
=head1 SYNOPSIS
@@ -10360,7 +10360,7 @@ =head1 HISTORY
=over 4
-=item B Released ????
+=item B Released ????
Support PostgreSQL 10.
(David Christensen, Christoph Berg)
diff --git a/check_postgres.pl.html b/check_postgres.pl.html
index 19921b5a..3ed2f043 100644
--- a/check_postgres.pl.html
+++ b/check_postgres.pl.html
@@ -111,7 +111,7 @@ NAME
check_postgres.pl - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.22.1
+This documents describes check_postgres.pl version 2.23.0
SYNOPSIS
@@ -1537,7 +1537,7 @@ HISTORY
-- Version 2.22.1 Released ????
+- Version 2.23.0 Released ????
-
Add Spanish message translations
From 57c5e1669467f8f2c50804a142353699b1db6749 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Sat, 9 Sep 2017 19:50:54 -0400
Subject: [PATCH 121/272] Spelling fix
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index bc310809..da691d1c 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -9889,7 +9889,7 @@ =head2 B
To replace the old stored file with the new version, use the --replace argument.
-If you need to write the stored file to a specific direectory, use
+If you need to write the stored file to a specific directory, use
the --audit-file-dir argument.
To avoid false positives on value based checks caused by replication lag on
From e1e1eb794d9fe9c0e88ad6c14257203a3584008a Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Sun, 24 Sep 2017 15:34:02 -0400
Subject: [PATCH 122/272] Add TODO item
---
TODO | 2 ++
1 file changed, 2 insertions(+)
diff --git a/TODO b/TODO
index ac5b900c..586eb55a 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,8 @@ Quick list of outstanding items / bugs / feature requests for CP:
NOTE: All bugzilla items are now on github
+* Add --setup and --reset flags to replicate_row to automate things.
+
* Add documentation on privs required for each action, and recommended grants for roles, etc.
* The same_schema action does not check indexes. See bugzilla #54
From c3a7dd60c82f08d3776bab0ec1ef54ee75659407 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Sun, 24 Sep 2017 15:58:57 -0400
Subject: [PATCH 123/272] Typo
---
check_postgres.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index da691d1c..b7df607d 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -6907,7 +6907,7 @@ sub check_same_schema {
## Set the total time
$db->{totaltime} = sprintf '%.2f', tv_interval($start);
- ## Before we outpu any results, rewrite the audit file if needed
+ ## Before we output any results, rewrite the audit file if needed
## We do this if we are reading from a saved file,
## and the "replace" argument is set
if ($samedb and $opt{replace}) {
From d7f64759781dc99a01988dc378238592bc35c147 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Sun, 24 Sep 2017 21:53:04 -0400
Subject: [PATCH 124/272] Tighten up test: use done_testing(), give skip() a
number
---
t/02_replication_slots.t | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
index 22ad1b36..2f5198f6 100644
--- a/t/02_replication_slots.t
+++ b/t/02_replication_slots.t
@@ -6,7 +6,7 @@ use 5.006;
use strict;
use warnings;
use Data::Dumper;
-use Test::More tests => 20;
+use Test::More;
use lib 't','.';
use CP_Testing;
@@ -77,7 +77,7 @@ $dbh->do ("SELECT pg_drop_replication_slot('cp_testing_slot')");
SKIP: {
- skip qq{Waiting for test_decoding plugin};
+ skip qq{Waiting for test_decoding plugin}, 10;
# To do more tests on physical slots we'd actually have to kick off some activity by performing a connection to them (.. use pg_receivexlog or similar??)
@@ -129,4 +129,6 @@ $dbh->do ("SELECT pg_drop_replication_slot('cp_testing_slot')");
}
+done_testing();
+
exit;
From ca1f541d67c32ad8b95a4ead2cdfd94be1b469cf Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Thu, 5 Oct 2017 10:26:34 +0200
Subject: [PATCH 125/272] t/02_replication_slots.t: Fix for PG < 9.4
---
t/02_replication_slots.t | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
index 2f5198f6..7c8cfef2 100644
--- a/t/02_replication_slots.t
+++ b/t/02_replication_slots.t
@@ -28,8 +28,9 @@ my $label = 'POSTGRES_REPLICATION_SLOTS';
my $ver = $dbh->{pg_server_version};
if ($ver < 90400) {
SKIP: {
- skip 'replication slots not present before 9.4', 20;
+ skip 'replication slots not present before 9.4', 1;
}
+ done_testing();
exit 0;
}
From 5ade2a3e41b6ee7852facd40118714683f2bc9b8 Mon Sep 17 00:00:00 2001
From: Michael Pirogov
Date: Thu, 19 Oct 2017 14:01:19 +0300
Subject: [PATCH 126/272] Support check_hot_standby_delay for PG10
---
check_postgres.pl | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index b7df607d..7f6a527c 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -5111,7 +5111,12 @@ sub check_hot_standby_delay {
my ($moffset, $s_rec_offset, $s_rep_offset, $time_delta);
## On slave
- $SQL = q{SELECT pg_last_xlog_receive_location() AS receive, pg_last_xlog_replay_location() AS replay};
+ if ($version >= 10) {
+ $SQL = q{SELECT pg_last_wal_receive_lsn() AS receive, pg_last_wal_replay_lsn() AS replay};
+ }
+ else {
+ $SQL = q{SELECT pg_last_xlog_receive_location() AS receive, pg_last_xlog_replay_location() AS replay};
+ }
if ($version >= 9.1) {
$SQL .= q{, COALESCE(ROUND(EXTRACT(epoch FROM now() - pg_last_xact_replay_timestamp())),0) AS seconds};
}
@@ -5141,7 +5146,12 @@ sub check_hot_standby_delay {
}
## On master
- $SQL = q{SELECT pg_current_xlog_location() AS location};
+ if ($version >= 10) {
+ $SQL = q{SELECT pg_current_wal_lsn() AS location};
+ }
+ else {
+ $SQL = q{SELECT pg_current_xlog_location() AS location};
+ }
$info = run_command($SQL, { dbnumber => $master });
for $db (@{$info->{db}}) {
my $location = $db->{slurp}[0]{location};
From 176a66df03925957ed59b869f4ccea6b86bdbd37 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Sun, 29 Oct 2017 18:50:24 +0100
Subject: [PATCH 127/272] Sleep longer in MRTG test, sometimes the result was
'0'
---
t/02_replicate_row.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/02_replicate_row.t b/t/02_replicate_row.t
index d8a63f97..ab627c01 100644
--- a/t/02_replicate_row.t
+++ b/t/02_replicate_row.t
@@ -146,7 +146,7 @@ if (fork) {
qr{^[1-5]\n0\n\n\n}, $t);
}
else {
- sleep 1;
+ sleep 2;
$SQL = q{UPDATE reptest SET foo = 'yin' WHERE id = 1};
$dbh2->do($SQL);
$dbh2->commit();
From 52f013646a20df859420622e8aeec47c530263bf Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 30 Oct 2017 09:56:47 -0500
Subject: [PATCH 128/272] Ignore Vagrant stuffs
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index 4489c953..318c2a28 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,5 @@ test_database_check_postgres*
cover_db/
check_postgres-
MYMETA.*
+/Vagrantfile
+.vagrant
From d295798c90b5cce288376df153f0a131d2147907 Mon Sep 17 00:00:00 2001
From: David Christensen
Date: Mon, 30 Oct 2017 09:57:10 -0500
Subject: [PATCH 129/272] Whack special-case logic for PG 10
---
.travis.yml | 6 ------
1 file changed, 6 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 743a5fe8..65a0cdbf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,12 +20,6 @@ perl:
- '5.24'
before_install:
- # apt.postgresql.org is already configured, we just need to add 10
- - |
- if [ "$PGVERSION" = "10" ]; then
- # update pgdg-source.list
- sudo sed -i -e 's/main/main 10/' /etc/apt/sources.list.d/pgdg*.list
- fi
- sudo apt-get -qq update
install:
From 36f17e0bcb9a248db85bc19b8a813f2e04549ab2 Mon Sep 17 00:00:00 2001
From: George Hansper
Date: Tue, 31 Oct 2017 14:50:31 +1100
Subject: [PATCH 130/272] #105 output per-database perfdata for pgbouncer pool
checks (was |time=0.01 time=0.01 time=0.01 ...)
---
check_postgres.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 7f6a527c..012afafb 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1741,7 +1741,7 @@ sub add_response {
$dbport;
$header =~ s/\s+$//;
$header =~ s/^ //;
- my $perf = ($opt{showtime} and $db->{totaltime} and $action ne 'bloat') ? "time=$db->{totaltime}s" : '';
+ my $perf = ($opt{showtime} and $db->{totaltime} and $action ne 'bloat' and $action !~ /^pgb_pool_/ ) ? "time=$db->{totaltime}s" : '';
if ($db->{perf}) {
$db->{perf} =~ s/^ +//;
if (length $same_schema_header) {
@@ -6259,6 +6259,7 @@ sub check_pgb_pool {
$statsmsg{$i->{database}} = msg('pgbouncer-pool', $i->{database}, $stat, $i->{$stat});
next;
}
+ $db->{perf} = sprintf ' %s=%s;%s;%s', $i->{database}, $i->{$stat}, $warning, $critical;
if ($critical and $i->{$stat} >= $critical) {
add_critical $msg;
From 627caca917875209efd6504a322715a34b872ff0 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 Oct 2017 12:13:26 +0100
Subject: [PATCH 131/272] Update project URLs
---
README.md | 7 +++----
check_postgres.pl | 25 +++++++++++++------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index 437e9cd9..917429b3 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ This is check_postgres, a monitoring tool for Postgres.
The most complete and up to date information about this script can be found at:
-https://bucardo.org/wiki/Check_postgres
+https://bucardo.org/Check_postgres/
You should go check there right now to make sure you are installing
the latest version!
@@ -28,7 +28,6 @@ file by:
Then join the announce mailing list (see below)
-
Complete method
---------------
@@ -74,7 +73,8 @@ https://mail.endcrypt.com/mailman/listinfo/check_postgres
Development happens via git. You can check out the repository by doing:
- git clone git://bucardo.org/check_postgres.git
+ https://github.com/bucardo/check_postgres
+ git clone https://github.com/bucardo/check_postgres.git
All changes are sent to the commit list:
@@ -85,7 +85,6 @@ COPYRIGHT
Copyright (c) 2007-2017 Greg Sabino Mullane
-
LICENSE INFORMATION
-------------------
diff --git a/check_postgres.pl b/check_postgres.pl
index 7f6a527c..0bf18849 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -9,7 +9,7 @@
## End Point Corporation http://www.endpoint.com/
## BSD licensed, see complete license at bottom of this script
## The latest version can be found at:
-## http://www.bucardo.org/check_postgres/
+## https://bucardo.org/Check_postgres/
##
## See the HISTORY section for other contributors
@@ -1530,7 +1530,7 @@ package check_postgres;
$ME --man
-Or visit: http://bucardo.org/check_postgres/
+Or visit: https://bucardo.org/Check_postgres/
};
@@ -5883,7 +5883,7 @@ sub check_new_version_bc {
## Check if a newer version of Bucardo is available
- my $url = 'http://bucardo.org/bucardo/latest_version.txt';
+ my $url = 'https://bucardo.org/bucardo/latest_version.txt';
find_new_version('Bucardo', 'bucardo_ctl', $url);
return;
@@ -5895,7 +5895,7 @@ sub check_new_version_box {
## Check if a newer version of boxinfo is available
- my $url = 'http://bucardo.org/boxinfo/latest_version.txt';
+ my $url = 'https://bucardo.org/boxinfo/latest_version.txt';
find_new_version('boxinfo', 'boxinfo.pl', $url);
return;
@@ -5907,7 +5907,7 @@ sub check_new_version_cp {
## Check if a new version of check_postgres.pl is available
- my $url = 'http://bucardo.org/check_postgres/latest_version.txt';
+ my $url = 'https://bucardo.org/check_postgres/latest_version.txt';
find_new_version('check_postgres', $VERSION, $url);
return;
@@ -5945,7 +5945,7 @@ sub check_new_version_tnm {
## Check if a new version of tail_n_mail is available
- my $url = 'http://bucardo.org/tail_n_mail/latest_version.txt';
+ my $url = 'https://bucardo.org/tail_n_mail/latest_version.txt';
find_new_version('tail_n_mail', 'tail_n_mail', $url);
return;
@@ -8454,7 +8454,7 @@ =head1 SYNOPSIS
## There are many other actions and options, please keep reading.
The latest news and documentation can always be found at:
- http://bucardo.org/check_postgres/
+ https://bucardo.org/Check_postgres/
=head1 DESCRIPTION
@@ -9549,7 +9549,7 @@ =head2 B
program is available. The current version is obtained by running C.
If a major upgrade is available, a warning is returned. If a revision upgrade is
available, a critical is returned. (Bucardo is a master to slave, and master to master
-replication system for Postgres: see http://bucardo.org for more information).
+replication system for Postgres: see https://bucardo.org/ for more information).
See also the information on the C<--get_method> option.
=head2 B
@@ -9559,7 +9559,7 @@ =head2 B
If a major upgrade is available, a warning is returned. If a revision upgrade is
available, a critical is returned. (boxinfo is a program for grabbing important
information from a server and putting it into a HTML format: see
-http://bucardo.org/wiki/boxinfo for more information). See also the information on
+https://bucardo.org/Boxinfo/ for more information). See also the information on
the C<--get_method> option.
=head2 B
@@ -9588,7 +9588,7 @@ =head2 B
C. If a major upgrade is available, a warning is returned. If a
revision upgrade is available, a critical is returned. (tail_n_mail is a log monitoring
tool that can send mail when interesting events appear in your Postgres logs.
-See: http://bucardo.org/wiki/Tail_n_mail for more information).
+See: https://bucardo.org/tail_n_mail/ for more information).
See also the information on the C<--get_method> option.
=head2 B
@@ -10345,7 +10345,8 @@ =head1 DEVELOPMENT
Development happens using the git system. You can clone the latest version by doing:
- git clone git://bucardo.org/check_postgres.git
+ https://github.com/bucardo/check_postgres
+ git clone https://github.com/bucardo/check_postgres.git
=head1 MAILING LIST
@@ -10370,7 +10371,7 @@ =head1 HISTORY
=over 4
-=item B Released ????
+=item B Released October 31, 2017
Support PostgreSQL 10.
(David Christensen, Christoph Berg)
From cbf2254da03e9245d54a26f37c99dea1e106696d Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 Oct 2017 12:20:02 +0100
Subject: [PATCH 132/272] Note that 00_release.t needs RELEASE_TESTING=1
---
README.dev | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.dev b/README.dev
index 8060b9d9..f21bfae3 100644
--- a/README.dev
+++ b/README.dev
@@ -24,7 +24,7 @@ Quick notes on the current release process:
* Make sure all changes are recorded in the relevant POD section.
* Add a release date next to the new version number
-* Change the version number everywhere (use prove -v t/00_release.t to verify)
+* Change the version number everywhere (use `RELEASE_TESTING=1 prove -v t/00_release.t` to verify)
* git commit as needed
* Run: perl Makefile.PL; make html
* Run: make signature_asc
From 98d0d1d40a21f26141c6122d44e29c8af624ae0c Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 Oct 2017 12:20:28 +0100
Subject: [PATCH 133/272] Add new files to MANIFEST
---
MANIFEST | 2 ++
MANIFEST.SKIP | 1 +
2 files changed, 3 insertions(+)
diff --git a/MANIFEST b/MANIFEST
index 4fc6dca9..ec6658ac 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,6 +1,7 @@
check_postgres.pl
check_postgres.pl.asc
check_postgres.pl.html
+LICENSE
README.md
SIGNATURE
Makefile.PL
@@ -8,6 +9,7 @@ MANIFEST
MANIFEST.SKIP
perlcriticrc
META.yml
+MYMETA.json
MYMETA.yml
TODO
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index 63d276f2..8f2691c0 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -16,6 +16,7 @@ t/99_perlcritic.t
t/99_pod.t
t/00_release.t
t/99_spellcheck.t
+.travis.yml
README.dev
.check_postgresrc
^blame
From 28a7b5932ba31cb1990a43926120177098662df8 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 Oct 2017 13:17:22 +0100
Subject: [PATCH 134/272] Add French translation for relsize-msg-indexes
---
check_postgres.pl | 1 +
1 file changed, 1 insertion(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 0bf18849..c4fbcbf8 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -767,6 +767,7 @@ package check_postgres;
'relsize-msg-reli' => q{la plus grosse relation est l'index « $1 » : $2},
'relsize-msg-relt' => q{la plus grosse relation est la table « $1 » : $2},
'relsize-msg-tab' => q{la plus grosse table est « $1 » : $2},
+ 'relsize-msg-indexes' => q{la table avec les plus grosses indices est « $1 » : $2},
'rep-badarg' => q{Argument repinfo invalide : 6 valeurs séparées par des virgules attendues},
'rep-duh' => q{Aucun sens à tester la réplication avec les mêmes valeurs},
'rep-fail' => q{Ligne non répliquée sur l'esclave $1},
From 928ac0f31d579ea4bef2f82d4021aec82186c7c9 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 Oct 2017 13:22:56 +0100
Subject: [PATCH 135/272] Don't complain about indexes_size total_relation_size
not being tested
index_size table_size indexes_size total_relation_size are all tested
via t/02_relation_size.t
---
t/00_test_tester.t | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/00_test_tester.t b/t/00_test_tester.t
index 7f6f55f5..7853b58c 100644
--- a/t/00_test_tester.t
+++ b/t/00_test_tester.t
@@ -33,8 +33,10 @@ for my $line (split /\n/ => $info) {
my $ok = 1;
for my $act (sort keys %action) {
## Special known exceptions
- next if $act eq 'table_size' or $act eq 'index_size';
- next if $act eq 'last_autoanalyze' or $act eq 'last_autovacuum';
+ next if grep { $act eq $_ } qw(
+ index_size table_size indexes_size total_relation_size
+ last_autoanalyze last_autovacuum
+ );
my $file = "t/02_$act.t";
if (! -e $file) {
From 9c4e6d6b4672ccb12eb413f10225347f12b4420e Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Tue, 31 Oct 2017 13:36:08 +0100
Subject: [PATCH 136/272] Update check_postgres.pl.html
---
check_postgres.pl.html | 127 ++++++++++++++++++++++++++++++++++-------
1 file changed, 106 insertions(+), 21 deletions(-)
diff --git a/check_postgres.pl.html b/check_postgres.pl.html
index 3ed2f043..11e27de7 100644
--- a/check_postgres.pl.html
+++ b/check_postgres.pl.html
@@ -47,9 +47,11 @@
- fsm_relations
- hitratio
- hot_standby_delay
+ - relation_size
- index_size
- table_size
- - relation_size
+ - indexes_size
+ - total_relation_size
- last_analyze
- last_vacuum
- last_autoanalyze
@@ -77,6 +79,7 @@
- query_runtime
- query_time
- replicate_row
+ - replication_slots
- same_schema
- sequence
- settings_checksum
@@ -133,7 +136,7 @@ SYNOPSIS
## There are many other actions and options, please keep reading.
The latest news and documentation can always be found at:
- http://bucardo.org/check_postgres/
+ https://bucardo.org/Check_postgres/
postgres@db$./check_postgres.pl --action=checkpoint --datadir /var/lib/postgresql/8.3/main/ --assume-prod
POSTGRES_CHECKPOINT OK: Last checkpoint was 72 seconds ago | age=72;;300 mode=MASTER
+If specified, indicates that any replication between servers is asynchronous. The option is only relevant for (symlink: check_postgres_same_schema
).
Example: postgres@db$./check_postgres.pl --action=same_schema --assume-async --dbhost=star,line
+The script runs one or more actions. This can either be done with the --action flag, or by using a symlink to the main file that contains the name of the action inside of it. For example, to run the action "timesync", you may either issue:
+The action to be run is selected using the --action flag, or by using a symlink to the main file that contains the name of the action inside of it. For example, to run the action "timesync", you may either issue:
check_postgres.pl --action=timesync
@@ -416,11 +427,11 @@ check_postgres_timesync
-All the symlinks are created for you in the current directory if use the option --symlinks
+All the symlinks are created for you in the current directory if use the option --symlinks:
perl check_postgres.pl --symlinks
-If the file name already exists, it will not be overwritten. If the file exists and is a symlink, you can force it to overwrite by using "--action=build_symlinks_force"
+If the file name already exists, it will not be overwritten. If the file exists and is a symlink, you can force it to overwrite by using "--action=build_symlinks_force".
Most actions take a --warning and a --critical option, indicating at what point we change from OK to WARNING, and what point we go to CRITICAL. Note that because criticals are always checked first, setting the warning equal to the critical is an effective way to turn warnings off and always give a critical.
@@ -428,7 +439,7 @@(symlink: check_postgres_archive_ready
) Checks how many WAL files with extension .ready exist in the pg_xlog/archive_status directory, which is found off of your data_directory. If the --lsfunc option is not used then this action must be run as a superuser, in order to access the contents of the pg_xlog/archive_status directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of .ready files in the pg_xlog/archive_status directory. Usually, these values should be low, turning on the archive mechanism, we usually want it to archive WAL files as fast as possible.
(symlink: check_postgres_archive_ready
) Checks how many WAL files with extension .ready exist in the pg_xlog/archive_status directory (PostgreSQL 10 and later: pg_wal/archive_status), which is found off of your data_directory. If the --lsfunc option is not used then this action must be run as a superuser, in order to access the contents of the pg_xlog/archive_status directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of .ready files in the pg_xlog/archive_status directory. Usually, these values should be low, turning on the archive mechanism, we usually want it to archive WAL files as fast as possible.
If the archive command fail, number of WAL in your pg_xlog directory will grow until exhausting all the disk space and force PostgreSQL to stop immediately.
@@ -771,7 +782,7 @@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)
+WAL file directory - The disk that the write-ahead logs are on (e.g. symlinked pg_xlog or pg_wal)
tablespaces - Each tablespace that is on a separate disk.
@@ -853,13 +864,27 @@ check_hot_standby_delay --dbhost=master,replica1 --warning='1048576 and 2 min' --critical='16777216 and 10 min'
+(symlinks: check_postgres_relation_size
, check_postgres_index_size
, check_postgres_table_size
, check_postgres_indexes_size
, and check_postgres_total_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 actions relation_size and index_size check for a relation (table, index, materialized view), respectively an index that has grown too big, using the pg_relation_size() function.
+ +The action table_size checks tables and materialized views using pg_table_size(), i.e. including relation forks and TOAST table.
+ +The action indexes_size checks tables and materialized views for the size of the attached indexes using pg_indexes_size().
+ +The action total_relation_size checks relations using pg_total_relation_size(), i.e. including relation forks, indexes and TOAST table.
+ +Relations 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.
@@ -951,11 +976,11 @@(symlink: check_postgres_new_version_bc
) Checks if a newer version of the Bucardo program is available. The current version is obtained by running bucardo_ctl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (Bucardo is a master to slave, and master to master replication system for Postgres: see http://bucardo.org for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_bc
) Checks if a newer version of the Bucardo program is available. The current version is obtained by running bucardo_ctl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (Bucardo is a master to slave, and master to master replication system for Postgres: see https://bucardo.org/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_box
) Checks if a newer version of the boxinfo program is available. The current version is obtained by running boxinfo.pl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (boxinfo is a program for grabbing important information from a server and putting it into a HTML format: see http://bucardo.org/wiki/boxinfo for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_box
) Checks if a newer version of the boxinfo program is available. The current version is obtained by running boxinfo.pl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (boxinfo is a program for grabbing important information from a server and putting it into a HTML format: see https://bucardo.org/Boxinfo/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_tnm
) Checks if a newer version of the tail_n_mail program is available. The current version is obtained by running tail_n_mail --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (tail_n_mail is a log monitoring tool that can send mail when interesting events appear in your Postgres logs. See: http://bucardo.org/wiki/Tail_n_mail for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_tnm
) Checks if a newer version of the tail_n_mail program is available. The current version is obtained by running tail_n_mail --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (tail_n_mail is a log monitoring tool that can send mail when interesting events appear in your Postgres logs. See: https://bucardo.org/tail_n_mail/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_query_time
) Checks the length of running queries on one or more databases. There is no need to run this more than once on the same database cluster. Note that this already excludes queries that are "idle in transaction". Databases can be filtered by using the --include and --exclude options. See the "BASIC FILTERING" section for more details. You can also filter on the user running the query with the --includeuser and --excludeuser options. See the "USER NAME FILTERING" section for more details.
The values for the --warning and --critical options are amounts of time, and default to '2 minutes' and '5 minutes' respectively. Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given, the unit is assumed to be seconds.
+The values for the --warning and --critical options are amounts of time, and at least one must be provided (no defaults). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given, the unit is assumed to be seconds.
This action requires Postgres 8.1 or better.
@@ -1110,6 +1135,16 @@For MRTG output, returns on the first line the time in seconds the replication takes to finish. The maximum time is set to 4 minutes 30 seconds: if no replication has taken place in that long a time, an error is thrown.
+(symlink: check_postgres_replication_slots
) Check the quantity of WAL retained for any replication slots in the target database cluster. This is handy for monitoring environments where all WAL archiving and replication is taking place over replication slots.
Warning and critical are total bytes retained for the slot. E.g:
+ + check_postgres_replication_slots --port=5432 --host=yellow -warning=32M -critical=64M
+
+Specific named slots can be monitored using --include/--exclude
+(symlink: check_postgres_same_schema
) Verifies that two or more databases are identical as far as their schema (but not the data within). This is particularly handy for making sure your slaves have not been modified or corrupted in any way when using master to slave replication. Unlike most other actions, this has no warning or critical criteria - the databases are either in sync, or are not. If they are different, a detailed list of the differences is presented.
To replace the old stored file with the new version, use the --replace argument.
-If you need to write the stored file to a specific direectory, use the --audit-file-dir argument.
+If you need to write the stored file to a specific directory, use the --audit-file-dir argument.
+ +To avoid false positives on value based checks caused by replication lag on asynchronous replicas, use the --assume-async option.
To enable snapshots at various points in time, you can use the "--suffix" argument to make the filenames unique to each run. See the examples below.
@@ -1199,6 +1236,10 @@ check_postgres_same_schema --dbname=cylon --suffix=daily --replace
+Example 7: Verify that two databases on hosts star and line are the same, excluding value data (i.e. sequence last_val):
+ + check_postgres_same_schema --dbhost=star,line --assume-async
+
(symlink: check_postgres_sequence
) Checks how much room is left on all sequences in the database. This is measured as the percent of total possible values that have been used for each sequence. The --warning and --critical options should be expressed as percentages. The default values are 85% for the warning and 95% for the critical. You may use --include and --exclude to control which sequences are to be checked. Note that this check does account for unusual minvalue and increment by values, but does not care if the sequence is set to cycle or not.
(symlink: check_postgres_txn_idle
) Checks the number and duration of "idle in transaction" queries on one or more databases. There is no need to run this more than once on the same database cluster. Databases can be filtered by using the --include and --exclude options. See the "BASIC FILTERING" section below for more details.
The --warning and --critical options are given as units of time, signed integers, or integers for units of time, and both must be provided (there are no defaults). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given and the numbers are unsigned, the units are assumed to be seconds.
+The --warning and --critical options are given as units of time, signed integers, or integers for units of time, and at least one must be provided (there are no defaults). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given and the numbers are unsigned, the units are assumed to be seconds.
This action requires Postgres 8.3 or better.
+As of PostgreSQL 10, you can just GRANT pg_read_all_stats to an unprivileged user account. In all earlier versions, superuser privileges are required to see the queries of all users in the system; UNKNOWN is returned if queries cannot be checked. To only include queries by the connecting user, use --includeuser.
+Example 1: Give a warning if any connection has been idle in transaction for more than 15 seconds:
check_postgres_txn_idle --port=5432 --warning='15 seconds'
@@ -1283,7 +1326,7 @@ (symlink: check_postgres_txn_time
) Checks the length of open transactions on one or more databases. There is no need to run this command more than once per database cluster. Databases can be filtered by use of the --include and --exclude options. See the "BASIC FILTERING" section for more details. The owner of the transaction can also be filtered, by use of the --includeuser and --excludeuser options. See the "USER NAME FILTERING" section for more details.
The values or the --warning and --critical options are units of time, and must be provided (no default). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given, the units are assumed to be seconds.
+The values or the --warning and --critical options are units of time, and at least one must be provided (no default). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given, the units are assumed to be seconds.
This action requires Postgres 8.3 or better.
@@ -1329,7 +1372,7 @@(symlink: check_postgres_wal_files
) Checks how many WAL files exist in the pg_xlog directory, which is found off of your data_directory, sometimes as a symlink to another physical disk for performance reasons. If the --lsfunc option is not used then this action must be run as a superuser, in order to access the contents of the pg_xlog directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of files in the pg_xlog directory. What number to set this to will vary, but a general guideline is to put a number slightly higher than what is normally there, to catch problems early.
(symlink: check_postgres_wal_files
) Checks how many WAL files exist in the pg_xlog directory (PostgreSQL 10 and later" pg_wal), which is found off of your data_directory, sometimes as a symlink to another physical disk for performance reasons. If the --lsfunc option is not used then this action must be run as a superuser, in order to access the contents of the pg_xlog directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of files in the pg_xlog directory. What number to set this to will vary, but a general guideline is to put a number slightly higher than what is normally there, to catch problems early.
Normally, WAL files are closed and then re-used, but a long-running open transaction, or a faulty archive_command script, may cause Postgres to create too many files. Ultimately, this will cause the disk they are on to run out of space, at which point Postgres will shut down.
@@ -1515,7 +1558,8 @@Development happens using the git system. You can clone the latest version by doing:
- git clone git://bucardo.org/check_postgres.git
+ https://github.com/bucardo/check_postgres
+ git clone git://bucardo.org/check_postgres.git
Add Spanish message translations
+ Support PostgreSQL 10.
+ (David Christensen, Christoph Berg)
+
+ Change table_size to use pg_table_size() on 9.0+, i.e. include the TOAST
+ table size in the numbers reported. Add new actions indexes_size and
+ total_relation_size, using the respective pg_indexes_size() and
+ pg_total_relation_size() functions. All size checks will now also check
+ materialized views where applicable.
+ (Christoph Berg)
+
+ Connection errors are now always critical, not unknown.
+ (Christoph Berg)
+
+ New action replication_slots checking if logical or physical replication
+ slots have accumulated too much data
+ (Glyn Astill)
+
+ Multiple same_schema improvements
+ (Glyn Astill)
+
+ Add Spanish message translations
(Luis Vazquez)
Allow a wrapper function to run wal_files and archive_ready actions as
@@ -1548,7 +1612,28 @@ HISTORY
(Joshua Elsasser)
Add some defensive casting to the bloat query
- (Greg Sabino Mullane)
+ (Greg Sabino Mullane)
+
+ Invoke psql with option -X
+ (Peter Eisentraut)
+
+ Update postgresql.org URLs to use https.
+ (Magnus Hagander)
+
+ check_txn_idle: Don't fail when query contains 'disabled' word
+ (Marco Nenciarini)
+
+ check_txn_idle: Use state_change instead of query_start.
+ (Sebastian Webber)
+
+ check_hot_standby_delay: Correct extra space in perfdata
+ (Adrien Nayrat)
+
+ Remove \r from psql output as it can confuse some regexes
+ (Greg Sabino Mullane)
+
+ Sort failed jobs in check_pgagent_jobs for stable output.
+ (Christoph Berg)
Example 2: Same as above, but skip tables belonging to the users 'eve' or 'mallory'
- check_postgres_last_vacuum --host=wormwood --warning='3d' --critical='7d' --excludeusers=eve,mallory
+ check_postgres_last_vacuum --host=wormwood --warning='3d' --critical='7d' --excludeuser=eve,mallory
For MRTG output, returns (on the first line) the LEAST amount of time in seconds since a table was last vacuumed or analyzed. The fourth line returns the name of the database and name of the table.
From d2962dee08305a11f2e667470501f693467ef46b Mon Sep 17 00:00:00 2001 From: Christoph Moench-Tegedercheck_postgres.pl - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.23.0
+This documents describes check_postgres.pl version 2.24.0
(symlink: check_postgres_sequence
) Checks how much room is left on all sequences in the database. This is measured as the percent of total possible values that have been used for each sequence. The --warning and --critical options should be expressed as percentages. The default values are 85% for the warning and 95% for the critical. You may use --include and --exclude to control which sequences are to be checked. Note that this check does account for unusual minvalue and increment by values, but does not care if the sequence is set to cycle or not.
(symlink: check_postgres_sequence
) Checks how much room is left on all sequences in the database. This is measured as the percent of total possible values that have been used for each sequence. The --warning and --critical options should be expressed as percentages. The default values are 85% for the warning and 95% for the critical. You may use --include and --exclude to control which sequences are to be checked. Note that this check does account for unusual minvalue and increment by values. By default it does not care if the sequence is set to cycle or not, and by passing --skipcycled sequenced set to cycle are reported with 0% usage.
The output for Nagios gives the name of the sequence, the percentage used, and the number of 'calls' left, indicating how many more times nextval can be called on that sequence before running into the maximum value.
@@ -1581,6 +1581,25 @@ Support new_version_pg for PG10
+ (Michael Pirogov)
+
+ Option to skip CYCLE sequences in action sequence
+ (Christoph Moench-Tegeder)
+
+ Output per-database perfdata for pgbouncer pool checks
+ (George Hansper)
+
+ German message translations
+ (Holger Jacobs)
+
+ Consider only client backends in query_time and friends
+ (David Christensen)
+
+Greg Sabino Mullane <greg@endpoint.com>
+Greg Sabino Mullane <greg@turnstep.com>
Copyright (c) 2007-2017 Greg Sabino Mullane <greg@endpoint.com>.
+Copyright (c) 2007-2019 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
diff --git a/set_translations.pl b/set_translations.pl index a4ab87be..2fa666a8 100755 --- a/set_translations.pl +++ b/set_translations.pl @@ -4,8 +4,7 @@ ## This only needs to be run by developers of check_postgres, and only rarely ## Usage: $0 --pgsrc=path to top of Postgres source tree ## -## Greg Sabino Mullanecheck_postgres.pl - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.24.0
+This documents describes check_postgres.pl version 2.25.0
Copyright (c) 2007-2019 Greg Sabino Mullane <greg@turnstep.com>.
+Copyright (c) 2007-2020 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From 0e18fe3c1f8f5656efd8ba2ee889fcdaa5bedabf Mon Sep 17 00:00:00 2001 From: Greg Sabino MullaneThe name of a service inside of the pg_service.conf file. Before version 9.0 of Postgres, this is a global file, usually found in /etc/pg_service.conf. If you are using version 9.0 or higher of Postgres, you can use the file ".pg_service.conf" in the home directory of the user running the script, e.g. nagios.
+The name of a service inside of the pg_service.conf file. Before version 9.0 of Postgres, this is a global file, usually found in /etc/pg_service.conf. If you are using version 9.0 or higher of Postgres, you can use the file ".pg_service.conf" in the home directory of the user running the script, e.g. nagios.
This file contains a simple list of connection options. You can also pass additional information when using this option such as --dbservice="maindatabase sslmode=require"
-The documentation for this file can be found at https://www.postgresql.org/docs/current/static/libpq-pgservice.html
+The documentation for this file can be found at https://www.postgresql.org/docs/current/static/libpq-pgservice.html
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)
+Example 2: Check that all file systems starting with /dev/sda are smaller than 10 GB and 11 GB (warning and critical)
check_postgres_disk_space --port=5432 --warning='10 GB' --critical='11 GB' --include="~^/dev/sda"
@@ -976,11 +976,11 @@ (symlink: check_postgres_new_version_bc
) Checks if a newer version of the Bucardo program is available. The current version is obtained by running bucardo_ctl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (Bucardo is a master to slave, and master to master replication system for Postgres: see https://bucardo.org/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_bc
) Checks if a newer version of the Bucardo program is available. The current version is obtained by running bucardo_ctl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (Bucardo is a master to slave, and master to master replication system for Postgres: see https://bucardo.org/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_box
) Checks if a newer version of the boxinfo program is available. The current version is obtained by running boxinfo.pl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (boxinfo is a program for grabbing important information from a server and putting it into a HTML format: see https://bucardo.org/Boxinfo/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_box
) Checks if a newer version of the boxinfo program is available. The current version is obtained by running boxinfo.pl --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (boxinfo is a program for grabbing important information from a server and putting it into a HTML format: see https://bucardo.org/Boxinfo/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_tnm
) Checks if a newer version of the tail_n_mail program is available. The current version is obtained by running tail_n_mail --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (tail_n_mail is a log monitoring tool that can send mail when interesting events appear in your Postgres logs. See: https://bucardo.org/tail_n_mail/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_new_version_tnm
) Checks if a newer version of the tail_n_mail program is available. The current version is obtained by running tail_n_mail --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (tail_n_mail is a log monitoring tool that can send mail when interesting events appear in your Postgres logs. See: https://bucardo.org/tail_n_mail/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_same_schema
) Verifies that two or more databases are identical as far as their schema (but not the data within). This is particularly handy for making sure your slaves have not been modified or corrupted in any way when using master to slave replication. Unlike most other actions, this has no warning or critical criteria - the databases are either in sync, or are not. If they are different, a detailed list of the differences is presented.
(symlink: check_postgres_same_schema
) Verifies that two or more databases are identical as far as their schema (but not the data within). Unlike most other actions, this has no warning or critical criteria - the databases are either in sync, or are not. If they are different, a detailed list of the differences is presented.
You may want to exclude or filter out certain differences. The way to do this is to add strings to the --filter
option. To exclude a type of object, use "noname", where 'name' is the type of object, for example, "noschema". To exclude objects of a certain type by a regular expression against their name, use "noname=regex". See the examples below for a better understanding.
In addition to command-line configurations, you can put any options inside of a file. The file .check_postgresrc in the current directory will be used if found. If not found, then the file ~/.check_postgresrc will be used. Finally, the file /etc/check_postgresrc will be used if available. The format of the file is option = value, one per line. Any line starting with a '#' will be skipped. Any values loaded from a check_postgresrc file will be overwritten by command-line options. All check_postgresrc files can be ignored by supplying a --no-checkpostgresrc
argument.
In addition to command-line configurations, you can put any options inside of a file. The file .check_postgresrc in the current directory will be used if found. If not found, then the file ~/.check_postgresrc will be used. Finally, the file /etc/check_postgresrc will be used if available. The format of the file is option = value, one per line. Any line starting with a '#' will be skipped. Any values loaded from a check_postgresrc file will be overwritten by command-line options. All check_postgresrc files can be ignored by supplying a --no-checkpostgresrc
argument.
Three mailing lists are available. For discussions about the program, bug reports, feature requests, and commit notices, send email to check_postgres@bucardo.org
-https://mail.endcrypt.com/mailman/listinfo/check_postgres
+https://mail.endcrypt.com/mailman/listinfo/check_postgres
A low-volume list for announcement of new versions and important notices is the 'check_postgres-announce' list:
-https://mail.endcrypt.com/mailman/listinfo/check_postgres-announce
+https://mail.endcrypt.com/mailman/listinfo/check_postgres-announce
Source code changes (via git-commit) are sent to the 'check_postgres-commit' list:
-https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit
+https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit
Allow same_schema objects to be included or excluded with --object and --skipobject
+ (Greg Sabino Mullane)
+
+ Fix to allow mixing service names and other connection parameters for same_schema
+ (Greg Sabino Mullane)
+
+Copyright (c) 2007-2020 Greg Sabino Mullane <greg@turnstep.com>.
+Copyright 2007-2021 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From f071638cbb4ded41ef04fb228a3307e7946d0941 Mon Sep 17 00:00:00 2001 From: Emre HasegeliCopyright 2007-2021 Greg Sabino Mullane <greg@turnstep.com>.
+Copyright 2007-2022 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From dfdde84cbcf757530addbdb766c6de2d710e3284 Mon Sep 17 00:00:00 2001 From: Jens WilkeCopyright 2007-2022 Greg Sabino Mullane <greg@turnstep.com>.
+Copyright 2007-2023 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From 5d7f4c4cdea10badbc53ee68ac456f91ec6ea07b Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullanecheck_postgres.pl - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.25.0
+This documents describes check_postgres.pl version 2.26.0
The documentation for this file can be found at https://www.postgresql.org/docs/current/static/libpq-pgservice.html
+Provides the role to switch to after connecting to the database but before running the given check. This provides the ability to have superuser privileges assigned to a role without LOGIN access for the purposes of audit and other security considerations. Requires a local `psql` version 9.6 or higher.
+If the archive command fail, number of WAL in your pg_xlog directory will grow until exhausting all the disk space and force PostgreSQL to stop immediately.
-To avoid connecting as a database superuser, a wrapper function around pg_ls_dir()
should be defined as a superuser with SECURITY DEFINER, and the --lsfunc option used. This example function, if defined by a superuser, will allow the script to connect as a normal user nagios with --lsfunc=ls_archive_status_dir
To avoid running as a database superuser, a wrapper function around pg_ls_dir()
should be defined as a superuser with SECURITY DEFINER, and the --lsfunc option used. This example function, if defined by a superuser, will allow the script to connect as a normal user nagios with --lsfunc=ls_archive_status_dir
BEGIN;
CREATE FUNCTION ls_archive_status_dir()
@@ -475,7 +482,7 @@ backends
(symlink: check_postgres_backends
) Checks the current number of connections for one or more databases, and optionally compares it to the maximum allowed, which is determined by the Postgres configuration variable max_connections. The --warning and --critical options can take one of three forms. First, a simple number can be given, which represents the number of connections at which the alert will be given. This choice does not use the max_connections setting. Second, the percentage of available connections can be given. Third, a negative number can be given which represents the number of connections left until max_connections is reached. The default values for --warning and --critical are '90%' and '95%'. You can also filter the databases by use of the --include and --exclude options. See the "BASIC FILTERING" section for more details.
-To view only non-idle processes, you can use the --noidle argument. Note that the user you are connecting as must be a superuser for this to work properly.
+To view only non-idle processes, you can use the --noidle argument. Note that the user you are running as (either connecting directly or switching via --role) must be a superuser for this to work properly.
Example 1: Give a warning when the number of connections on host quirm reaches 120, and a critical if it reaches 150.
@@ -774,7 +781,7 @@ disabled_triggers
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 or both. 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%'.
+(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 (either connecting directly or switching via --role), so it can examine the data_directory setting inside of Postgres. The --warning and --critical options are given in either sizes or percentages or both. 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.
@@ -1018,7 +1025,7 @@ pgbouncer_backends
(symlink: check_postgres_pgbouncer_backends
) Checks the current number of connections for one or more databases through pgbouncer, and optionally compares it to the maximum allowed, which is determined by the pgbouncer configuration variable max_client_conn. The --warning and --critical options can take one of three forms. First, a simple number can be given, which represents the number of connections at which the alert will be given. This choice does not use the max_connections setting. Second, the percentage of available connections can be given. Third, a negative number can be given which represents the number of connections left until max_connections is reached. The default values for --warning and --critical are '90%' and '95%'. You can also filter the databases by use of the --include and --exclude options. See the "BASIC FILTERING" section for more details.
-To view only non-idle processes, you can use the --noidle argument. Note that the user you are connecting as must be a superuser for this to work properly.
+To view only non-idle processes, you can use the --noidle argument. Note that the user you are running as (either connecting directly or switching via --role) must be a superuser for this to work properly.
Example 1: Give a warning when the number of connections on host quirm reaches 120, and a critical if it reaches 150.
@@ -1050,6 +1057,18 @@ pgbouncer_checksum
For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A checksum must be provided as the --mrtg
argument. The fourth line always gives the current checksum.
+pgbouncer_maxwait
+
+(symlink: check_postgres_pgbouncer_maxwait
) Checks how long the first (oldest) client in the queue has been waiting, in seconds. If this starts increasing, then the current pool of servers does not handle requests quick enough. Reason may be either overloaded server or just too small of a pool_size setting in pbouncer config file. Databases can be filtered by use of the --include and --exclude options. See the "BASIC FILTERING" section for more details. The values or the --warning and --critical options are units of time, and must be provided (no default). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given, the units are assumed to be seconds.
+
+This action requires Postgres 8.3 or better.
+
+Example 1: Give a critical if any transaction has been open for more than 10 minutes:
+
+ check_postgres_pgbouncer_maxwait -p 6432 -u pgbouncer --critical='10 minutes'
+
+For MRTG output, returns the maximum time in seconds a transaction has been open on the first line. The fourth line gives the name of the database.
+
pgagent_jobs
(symlink: check_postgres_pgagent_jobs
) Checks that all the pgAgent jobs that have executed in the preceding interval of time have succeeded. This is done by checking for any steps that have a non-zero result.
@@ -1436,6 +1455,10 @@ BASIC FILTERING
--exclude='pg_catalog.'
+Exclude all items in the 'pg_temp_nnn' per-session temporary schemas:
+
+ --exclude=~^pg_temp_.
+
Exclude all items containing the letters 'ace', but allow the item 'faceoff':
--exclude=~ace --include=faceoff
@@ -1581,6 +1604,32 @@ HISTORY
+- Version 2.26.0 Not yet released
+-
+
+
Add new action "pgbouncer_maxwait" (Ruslan Kabalin) [Github pull #59]
+
+ Fix check_replication_slots on recently promoted servers (Christoph Berg)
+
+ Allow the check_disk_space action to handle relative log_directory paths (jacksonfoz) [Github pull #174]
+
+ Fix MINPAGES and MINIPAGES in the "check_bloat" action (Christoph Moench-Tegeder) [Github pull #82]
+
+ Replace 'which' with 'command -v' (Christoph Berg)
+
+ Fix check_replication_slots on recently promoted servers (Christoph Berg)
+
+ Add --role flag to explicitly set the role of the user after connecting (David Christensen)
+
+ Add Partman premake check (Jens Wilke) [Github pull #196]
+
+ Add to docs how to exclude all items in the 'pg_temp_nnn' per-session temporary schemas (Michael Banck)
+
+ Various fixes for the CI system (Emre Hasegeli) [Github pull #181]
+
+ Various improvements to the tests (Christoph Berg, Emre Hasegeli)
+
+
- Version 2.25.0 Released February 3, 2020
-
@@ -2614,7 +2663,7 @@
NAGIOS EXAMPLES
LICENSE AND COPYRIGHT
-Copyright 2007-2023 Greg Sabino Mullane <greg@turnstep.com>.
+Copyright 2007 - 2023 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From 7529d2daad009314fef25e2c02937f8c78c7d1b7 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 13:11:37 -0400
Subject: [PATCH 255/272] Small change to PR 158, add credit
---
check_postgres.pl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 296866a0..fd8e1e2b 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -9074,7 +9074,7 @@ sub check_txn_idle {
$maxr->{client_addr} eq '' ? '' : (sprintf ' %s:%s', msg('address'), $maxr->{client_addr}),
($maxr->{client_port} eq '' or $maxr->{client_port} < 1)
? '' : (sprintf ' %s:%s', msg('port'), $maxr->{client_port}),
- msg('query'), defined($maxr->{query}) ? $maxr->{query} : $maxr->{current_query};
+ msg('query'), $maxr->{query} // $maxr->{current_query};
}
## For MRTG, we can simply exit right now
@@ -11330,13 +11330,15 @@ =head1 HISTORY
Fix MINPAGES and MINIPAGES in the "check_bloat" action (Christoph Moench-Tegeder) [Github pull #82]
+ Add Partman premake check (Jens Wilke) [Github pull #196]
+
Replace 'which' with 'command -v' (Christoph Berg)
Fix check_replication_slots on recently promoted servers (Christoph Berg)
Add --role flag to explicitly set the role of the user after connecting (David Christensen)
- Add Partman premake check (Jens Wilke) [Github pull #196]
+ Fix undefined variable warning (Michael van Bracht) [Github pull #158]
Add to docs how to exclude all items in the 'pg_temp_nnn' per-session temporary schemas (Michael Banck)
From 16e051a92474d5e5a7c11c08bedc5bb1c7452539 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 13:15:28 -0400
Subject: [PATCH 256/272] Attribution for PR 86
---
check_postgres.pl | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 29dc2e8c..140646b7 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -11368,20 +11368,23 @@ =head1 HISTORY
Add new action "pgbouncer_maxwait" (Ruslan Kabalin) [Github pull #59]
+ For the bloat check, add option to populate all known databases,
+ as well as includsion and exclusion regexes. (Giles Westwood) [Github pull #86]
+
+ Add Partman premake check (Jens Wilke) [Github pull #196]
+
+ Add --role flag to explicitly set the role of the user after connecting (David Christensen)
+
Fix check_replication_slots on recently promoted servers (Christoph Berg)
Allow the check_disk_space action to handle relative log_directory paths (jacksonfoz) [Github pull #174]
Fix MINPAGES and MINIPAGES in the "check_bloat" action (Christoph Moench-Tegeder) [Github pull #82]
- Add Partman premake check (Jens Wilke) [Github pull #196]
-
Replace 'which' with 'command -v' (Christoph Berg)
Fix check_replication_slots on recently promoted servers (Christoph Berg)
- Add --role flag to explicitly set the role of the user after connecting (David Christensen)
-
Fix undefined variable warning (Michael van Bracht) [Github pull #158]
Add to docs how to exclude all items in the 'pg_temp_nnn' per-session temporary schemas (Michael Banck)
@@ -11390,7 +11393,6 @@ =head1 HISTORY
Various improvements to the tests (Christoph Berg, Emre Hasegeli)
-
=item B Released February 3, 2020
Allow same_schema objects to be included or excluded with --object and --skipobject
From 8e783d02554d128261d45571508c3f0d69928c4d Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 13:17:30 -0400
Subject: [PATCH 257/272] Attribution for PR 185
---
check_postgres.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 140646b7..5393fce5 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -11387,6 +11387,8 @@ =head1 HISTORY
Fix undefined variable warning (Michael van Bracht) [Github pull #158]
+ In the tests, force log_destination to stderr (Christoph Moench-Tegeder) [Github pull #185]
+
Add to docs how to exclude all items in the 'pg_temp_nnn' per-session temporary schemas (Michael Banck)
Various fixes for the CI system (Emre Hasegeli) [Github pull #181]
From 4d53f06f77d244f321f4601d1ac472c0a31e32eb Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 13:22:10 -0400
Subject: [PATCH 258/272] Remove mentions of the dead mailing lists
---
META.yml | 1 -
README.md | 16 ----------------
2 files changed, 17 deletions(-)
diff --git a/META.yml b/META.yml
index 79fbc94a..079f89c5 100644
--- a/META.yml
+++ b/META.yml
@@ -44,7 +44,6 @@ resources:
homepage : http://bucardo.org/check_postgres/
license : http://bucardo.org/check_postgres/
bugtracker : https://github.com/bucardo/check_postgres/issues
- MailingList : https://mail.endcrypt.com/mailman/listinfo/check_postgres
Repository : git://bucardo.org/check_postgres.git
meta-spec:
diff --git a/README.md b/README.md
index f759f27c..e2b89f2c 100644
--- a/README.md
+++ b/README.md
@@ -23,8 +23,6 @@ file by:
cd postgres
perl ../check_postgres.pl --symlinks
-Then join the announce mailing list (see below)
-
Complete method
---------------
@@ -54,20 +52,6 @@ The HTML version of the documentation is also available at:
https://bucardo.org/check_postgres/check_postgres.pl.html
-Mailing lists
--------------
-
-The final step should be to subscribe to the low volume check_postgres-announce
-mailing list, so you learn of new versions and important changes. Information
-on joining can be found at:
-
-https://mail.endcrypt.com/mailman/listinfo/check_postgres-announce
-
-General questions and development issues are discussed on the check_postgres list,
-which we recommend people join as well:
-
-https://mail.endcrypt.com/mailman/listinfo/check_postgres
-
Development happens via git. You can check out the repository by doing:
https://github.com/bucardo/check_postgres
From d0bba94836b2029109c487ed0f800fecd61ab2e9 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 13:23:55 -0400
Subject: [PATCH 259/272] Set release date for 2.26.0 as April 3, 2023
---
check_postgres.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 5393fce5..5764ebe7 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -11364,7 +11364,7 @@ =head1 HISTORY
=over 4
-=item B Not yet released
+=item B Released April 3, 2023
Add new action "pgbouncer_maxwait" (Ruslan Kabalin) [Github pull #59]
@@ -11395,6 +11395,7 @@ =head1 HISTORY
Various improvements to the tests (Christoph Berg, Emre Hasegeli)
+
=item B Released February 3, 2020
Allow same_schema objects to be included or excluded with --object and --skipobject
From e755e708f7906a60b3f54d4487fd3cc91aa1e002 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 13:54:14 -0400
Subject: [PATCH 260/272] Proposed fix for issue 133: no commas in pgpass field
---
check_postgres.pl | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 5764ebe7..0d83766b 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -3426,6 +3426,17 @@ sub setup_target_databases {
my %group;
my $found_new_var = 0;
+ ## Do we have any using multiple values for non-passwords?
+ my $got_multiple = 0;
+ for my $v (keys %$conn) {
+ next if $v eq 'dbpass' or ! defined $opt{$v}[0];
+ my $num = $opt{$v}->@*;
+ if ($num > 1 or $opt{$v}[0] =~ /,/) {
+ $got_multiple = 1;
+ last;
+ }
+ }
+
for my $v (keys %$conn) { ## For each connection var such as port, host...
my $vname = $v;
@@ -3438,7 +3449,7 @@ sub setup_target_databases {
$new =~ s/\s+//g unless $vname eq 'dbservice' or $vname eq 'host';
## Set this as the new default for this connection var moving forward
- $conn->{$vname} = [split /,/ => $new, -1];
+ $conn->{$vname} = $got_multiple ? [split /,/ => $new, -1] : [$new];
## Make a note that we found something new this round
$found_new_var = 1;
@@ -11364,6 +11375,11 @@ =head1 HISTORY
=over 4
+=item B not yet released
+
+ Allow commas in passwords via --dbpass for one-connection queries (Greg Sabino Mullane) [Github issue #133]
+
+
=item B Released April 3, 2023
Add new action "pgbouncer_maxwait" (Ruslan Kabalin) [Github pull #59]
From cf2dc459856ce17689ecc816ce1ec04e8ff93e91 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 14:00:31 -0400
Subject: [PATCH 261/272] Fix undefined var per issue 141
---
check_postgres.pl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 0d83766b..d872f5cb 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1792,7 +1792,7 @@ package check_postgres;
our $VERBOSE = $opt{verbose} || 0;
$VERBOSE = 5 if $opt{vv};
-our $OUTPUT = lc($opt{output} || '');
+our $OUTPUT = lc($opt{output} // '');
## Allow the optimization of the get_methods list by an argument
if ($opt{get_method}) {
@@ -11379,6 +11379,8 @@ =head1 HISTORY
Allow commas in passwords via --dbpass for one-connection queries (Greg Sabino Mullane) [Github issue #133]
+ Fix undefined variable error (Greg Sabino Mullane) [Github issue #141]
+
=item B Released April 3, 2023
From 6b454f35e4ec5cb1f11dde7263fe75422132fa93 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 14:03:34 -0400
Subject: [PATCH 262/272] Bump minimum Perl version to 5.10 to support the //
operator
---
META.yml | 2 +-
Makefile.PL | 2 +-
check_postgres.pl | 4 +++-
set_translations.pl | 2 +-
t/00_basic.t | 2 +-
t/00_release.t | 2 +-
t/00_signature.t | 2 +-
t/00_test_tester.t | 2 +-
t/01_validate_range.t | 2 +-
t/02_autovac_freeze.t | 2 +-
t/02_backends.t | 2 +-
t/02_bloat.t | 2 +-
t/02_checkpoint.t | 2 +-
t/02_cluster_id.t | 2 +-
t/02_commitratio.t | 2 +-
t/02_connection.t | 2 +-
t/02_custom_query.t | 2 +-
t/02_database_size.t | 2 +-
t/02_dbstats.t | 2 +-
t/02_disabled_triggers.t | 2 +-
t/02_disk_space.t | 2 +-
t/02_fsm_pages.t | 2 +-
t/02_fsm_relations.t | 2 +-
t/02_hitratio.t | 2 +-
t/02_last_analyze.t | 2 +-
t/02_last_vacuum.t | 2 +-
t/02_listener.t | 2 +-
t/02_locks.t | 2 +-
t/02_logfile.t | 2 +-
t/02_new_version_bc.t | 2 +-
t/02_new_version_box.t | 2 +-
t/02_new_version_cp.t | 2 +-
t/02_new_version_pg.t | 2 +-
t/02_new_version_tnm.t | 2 +-
t/02_pgagent_jobs.t | 2 +-
t/02_pgbouncer_checksum.t | 2 +-
t/02_prepared_txns.t | 2 +-
t/02_query_runtime.t | 2 +-
t/02_query_time.t | 2 +-
t/02_relation_size.t | 2 +-
t/02_replicate_row.t | 2 +-
t/02_replication_slots.t | 2 +-
t/02_same_schema.t | 2 +-
t/02_sequence.t | 2 +-
t/02_settings_checksum.t | 2 +-
t/02_slony_status.t | 2 +-
t/02_timesync.t | 2 +-
t/02_txn_idle.t | 2 +-
t/02_txn_time.t | 2 +-
t/02_txn_wraparound.t | 2 +-
t/02_version.t | 2 +-
t/02_wal_files.t | 2 +-
t/03_translations.t | 2 +-
t/04_timeout.t | 2 +-
t/05_docs.t | 2 +-
t/99_cleanup.t | 2 +-
t/99_perlcritic.t | 2 +-
t/99_pod.t | 2 +-
t/99_spellcheck.t | 2 +-
t/CP_Testing.pm | 2 +-
60 files changed, 62 insertions(+), 60 deletions(-)
diff --git a/META.yml b/META.yml
index 079f89c5..e66e9b25 100644
--- a/META.yml
+++ b/META.yml
@@ -10,7 +10,7 @@ distribution_type : script
dynamic_config : 0
requires:
- perl : 5.008
+ perl : 5.10.0
build_requires:
Test::More : 0.61
recommends:
diff --git a/Makefile.PL b/Makefile.PL
index 63ca101b..729cc1a4 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,7 +4,7 @@ use ExtUtils::MakeMaker qw/WriteMakefile/;
use Config;
use strict;
use warnings;
-use 5.008;
+use 5.10.0;
my $VERSION = '2.26.0';
diff --git a/check_postgres.pl b/check_postgres.pl
index d872f5cb..36de3fa5 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -16,7 +16,7 @@
package check_postgres;
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use utf8;
@@ -11377,6 +11377,8 @@ =head1 HISTORY
=item B not yet released
+ Raise minimum version or Perl to 5.10.0
+
Allow commas in passwords via --dbpass for one-connection queries (Greg Sabino Mullane) [Github issue #133]
Fix undefined variable error (Greg Sabino Mullane) [Github issue #141]
diff --git a/set_translations.pl b/set_translations.pl
index 2c992111..02a810b1 100755
--- a/set_translations.pl
+++ b/set_translations.pl
@@ -7,7 +7,7 @@
## Greg Sabino Mullane
## BSD licensed
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use utf8;
diff --git a/t/00_basic.t b/t/00_basic.t
index 7b13c56e..fc0597e5 100644
--- a/t/00_basic.t
+++ b/t/00_basic.t
@@ -2,7 +2,7 @@
## Simply test that the script compiles and gives a valid version
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Test::More tests => 2;
diff --git a/t/00_release.t b/t/00_release.t
index 7ea58fe8..ca785c2c 100644
--- a/t/00_release.t
+++ b/t/00_release.t
@@ -4,7 +4,7 @@
## 1. Make sure the version number is consistent in all places
## 2. Make sure we have a valid tag for this release
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/00_signature.t b/t/00_signature.t
index c6687fab..288ae9bf 100644
--- a/t/00_signature.t
+++ b/t/00_signature.t
@@ -2,7 +2,7 @@
## Test that our PGP signature file is valid
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Test::More;
diff --git a/t/00_test_tester.t b/t/00_test_tester.t
index 60062530..47f38168 100644
--- a/t/00_test_tester.t
+++ b/t/00_test_tester.t
@@ -2,7 +2,7 @@
## Make sure we have tests for all actions
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/01_validate_range.t b/t/01_validate_range.t
index 7ef57bd8..69c52f6e 100644
--- a/t/01_validate_range.t
+++ b/t/01_validate_range.t
@@ -2,7 +2,7 @@
## Test the "validate_range" function
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Test::More tests => 144;
diff --git a/t/02_autovac_freeze.t b/t/02_autovac_freeze.t
index 0c08a227..e206432e 100644
--- a/t/02_autovac_freeze.t
+++ b/t/02_autovac_freeze.t
@@ -2,7 +2,7 @@
## Test the "autovac_freeze" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_backends.t b/t/02_backends.t
index dc8072df..e11e20a9 100644
--- a/t/02_backends.t
+++ b/t/02_backends.t
@@ -2,7 +2,7 @@
## Test the "backends" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_bloat.t b/t/02_bloat.t
index 8fb3b405..d0e19602 100644
--- a/t/02_bloat.t
+++ b/t/02_bloat.t
@@ -2,7 +2,7 @@
## Test the "bloat" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_checkpoint.t b/t/02_checkpoint.t
index 899ccd73..4420eb52 100644
--- a/t/02_checkpoint.t
+++ b/t/02_checkpoint.t
@@ -2,7 +2,7 @@
## Test the "checkpoint" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_cluster_id.t b/t/02_cluster_id.t
index 551c493b..c9a5b91c 100644
--- a/t/02_cluster_id.t
+++ b/t/02_cluster_id.t
@@ -2,7 +2,7 @@
## Test the "checkpoint" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_commitratio.t b/t/02_commitratio.t
index 78ce26ed..4ccdc698 100644
--- a/t/02_commitratio.t
+++ b/t/02_commitratio.t
@@ -2,7 +2,7 @@
## Test the "commitratio" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_connection.t b/t/02_connection.t
index 5beb74e2..68108395 100644
--- a/t/02_connection.t
+++ b/t/02_connection.t
@@ -2,7 +2,7 @@
## Test the "connection" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_custom_query.t b/t/02_custom_query.t
index f14b658f..d4a8f006 100644
--- a/t/02_custom_query.t
+++ b/t/02_custom_query.t
@@ -2,7 +2,7 @@
## Test the "custom_query" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_database_size.t b/t/02_database_size.t
index 75c36e17..a4e11174 100644
--- a/t/02_database_size.t
+++ b/t/02_database_size.t
@@ -2,7 +2,7 @@
## Test the "database_size" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_dbstats.t b/t/02_dbstats.t
index dad37cc3..4dfa48f0 100644
--- a/t/02_dbstats.t
+++ b/t/02_dbstats.t
@@ -2,7 +2,7 @@
## Test the "dbstats" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_disabled_triggers.t b/t/02_disabled_triggers.t
index 3a6002a1..f005b603 100644
--- a/t/02_disabled_triggers.t
+++ b/t/02_disabled_triggers.t
@@ -2,7 +2,7 @@
## Test the "disabled_triggers" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_disk_space.t b/t/02_disk_space.t
index 4ab7e43b..c92cc124 100644
--- a/t/02_disk_space.t
+++ b/t/02_disk_space.t
@@ -2,7 +2,7 @@
## Test the "disk_space" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_fsm_pages.t b/t/02_fsm_pages.t
index b52608b4..68619716 100644
--- a/t/02_fsm_pages.t
+++ b/t/02_fsm_pages.t
@@ -2,7 +2,7 @@
## Test the "fsm_pages" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_fsm_relations.t b/t/02_fsm_relations.t
index a762a8eb..0ed32f41 100644
--- a/t/02_fsm_relations.t
+++ b/t/02_fsm_relations.t
@@ -2,7 +2,7 @@
## Test the "fsm_relations" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_hitratio.t b/t/02_hitratio.t
index e9f3ba49..1022db9e 100644
--- a/t/02_hitratio.t
+++ b/t/02_hitratio.t
@@ -2,7 +2,7 @@
## Test the "hitratio" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_last_analyze.t b/t/02_last_analyze.t
index 304eebef..899d0fa0 100644
--- a/t/02_last_analyze.t
+++ b/t/02_last_analyze.t
@@ -2,7 +2,7 @@
## Test the "last_analyze" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_last_vacuum.t b/t/02_last_vacuum.t
index 7cc1c06d..87a62450 100644
--- a/t/02_last_vacuum.t
+++ b/t/02_last_vacuum.t
@@ -2,7 +2,7 @@
## Test the "last_vacuum" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_listener.t b/t/02_listener.t
index 78a80bc0..6671dc4d 100644
--- a/t/02_listener.t
+++ b/t/02_listener.t
@@ -2,7 +2,7 @@
## Test the "listener" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_locks.t b/t/02_locks.t
index ef50e1b5..d03ddb76 100644
--- a/t/02_locks.t
+++ b/t/02_locks.t
@@ -2,7 +2,7 @@
## Test the "locks" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_logfile.t b/t/02_logfile.t
index 6456c06d..0bfb381c 100644
--- a/t/02_logfile.t
+++ b/t/02_logfile.t
@@ -3,7 +3,7 @@
## Test the "logfile" action
## this does not test $S for syslog or stderr output
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_new_version_bc.t b/t/02_new_version_bc.t
index f7edc7c9..0618bf9b 100644
--- a/t/02_new_version_bc.t
+++ b/t/02_new_version_bc.t
@@ -2,7 +2,7 @@
## Test the "new_version_bc" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_new_version_box.t b/t/02_new_version_box.t
index 45310956..c4bd42bd 100644
--- a/t/02_new_version_box.t
+++ b/t/02_new_version_box.t
@@ -2,7 +2,7 @@
## Test the "new_version_box" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_new_version_cp.t b/t/02_new_version_cp.t
index b32ceddf..3da86f75 100644
--- a/t/02_new_version_cp.t
+++ b/t/02_new_version_cp.t
@@ -2,7 +2,7 @@
## Test the "new_version_cp" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_new_version_pg.t b/t/02_new_version_pg.t
index 3b5bdba2..1220237f 100644
--- a/t/02_new_version_pg.t
+++ b/t/02_new_version_pg.t
@@ -2,7 +2,7 @@
## Test the "new_version_pg" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_new_version_tnm.t b/t/02_new_version_tnm.t
index 622db5f7..06c173fe 100644
--- a/t/02_new_version_tnm.t
+++ b/t/02_new_version_tnm.t
@@ -2,7 +2,7 @@
## Test the "new_version_tnm" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_pgagent_jobs.t b/t/02_pgagent_jobs.t
index b56d1d92..bb13c44c 100644
--- a/t/02_pgagent_jobs.t
+++ b/t/02_pgagent_jobs.t
@@ -2,7 +2,7 @@
## Test the "pgagent_jobs" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Test::More tests => 48;
diff --git a/t/02_pgbouncer_checksum.t b/t/02_pgbouncer_checksum.t
index 1fae6ddb..4a8ae81d 100644
--- a/t/02_pgbouncer_checksum.t
+++ b/t/02_pgbouncer_checksum.t
@@ -2,7 +2,7 @@
## Test the "pgbouncer_checksum" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_prepared_txns.t b/t/02_prepared_txns.t
index 68c69802..e16493d9 100644
--- a/t/02_prepared_txns.t
+++ b/t/02_prepared_txns.t
@@ -2,7 +2,7 @@
## Test the "prepare_txns" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_query_runtime.t b/t/02_query_runtime.t
index 2220466a..6d02ab3c 100644
--- a/t/02_query_runtime.t
+++ b/t/02_query_runtime.t
@@ -2,7 +2,7 @@
## Test the "query_runtime" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_query_time.t b/t/02_query_time.t
index cff23c7c..282a40f8 100644
--- a/t/02_query_time.t
+++ b/t/02_query_time.t
@@ -2,7 +2,7 @@
## Test the "query_time" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_relation_size.t b/t/02_relation_size.t
index e97a160d..8c725747 100644
--- a/t/02_relation_size.t
+++ b/t/02_relation_size.t
@@ -2,7 +2,7 @@
## Test the "relation_size" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_replicate_row.t b/t/02_replicate_row.t
index 1f203cc2..02a652f9 100644
--- a/t/02_replicate_row.t
+++ b/t/02_replicate_row.t
@@ -2,7 +2,7 @@
## Test the "replicate_row" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_replication_slots.t b/t/02_replication_slots.t
index 754dc4f7..c63c8ec7 100644
--- a/t/02_replication_slots.t
+++ b/t/02_replication_slots.t
@@ -2,7 +2,7 @@
## Test the "replication_slots" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_same_schema.t b/t/02_same_schema.t
index ccafb6ec..478d3d83 100644
--- a/t/02_same_schema.t
+++ b/t/02_same_schema.t
@@ -2,7 +2,7 @@
## Test the "same_schema" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_sequence.t b/t/02_sequence.t
index 68e92ae1..050764f2 100644
--- a/t/02_sequence.t
+++ b/t/02_sequence.t
@@ -2,7 +2,7 @@
## Test the "sequence" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_settings_checksum.t b/t/02_settings_checksum.t
index 34529252..3374aea2 100644
--- a/t/02_settings_checksum.t
+++ b/t/02_settings_checksum.t
@@ -2,7 +2,7 @@
## Test the "settings_checksum" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_slony_status.t b/t/02_slony_status.t
index 0314284f..31836c49 100644
--- a/t/02_slony_status.t
+++ b/t/02_slony_status.t
@@ -2,7 +2,7 @@
## Test the "slony_status" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_timesync.t b/t/02_timesync.t
index 0abecb61..2df8f785 100644
--- a/t/02_timesync.t
+++ b/t/02_timesync.t
@@ -2,7 +2,7 @@
## Test of the the "version" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_txn_idle.t b/t/02_txn_idle.t
index b552a0bc..a0e98473 100644
--- a/t/02_txn_idle.t
+++ b/t/02_txn_idle.t
@@ -2,7 +2,7 @@
## Test the "txn_idle" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_txn_time.t b/t/02_txn_time.t
index cbd2af42..6b7ed00c 100644
--- a/t/02_txn_time.t
+++ b/t/02_txn_time.t
@@ -2,7 +2,7 @@
## Test the "txn_time" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_txn_wraparound.t b/t/02_txn_wraparound.t
index 4eae698a..eb9c6dbf 100644
--- a/t/02_txn_wraparound.t
+++ b/t/02_txn_wraparound.t
@@ -2,7 +2,7 @@
## Test the "txn_wraparound" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_version.t b/t/02_version.t
index 97e7d4bf..8ff84294 100644
--- a/t/02_version.t
+++ b/t/02_version.t
@@ -2,7 +2,7 @@
## Test the "version" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/02_wal_files.t b/t/02_wal_files.t
index 84bded2b..988e8180 100644
--- a/t/02_wal_files.t
+++ b/t/02_wal_files.t
@@ -2,7 +2,7 @@
## Test the "wal_files" action
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/03_translations.t b/t/03_translations.t
index 8b057eb9..ca199219 100644
--- a/t/03_translations.t
+++ b/t/03_translations.t
@@ -2,7 +2,7 @@
## Run some sanity checks on the translations
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/04_timeout.t b/t/04_timeout.t
index 7c9b0008..435f70f1 100644
--- a/t/04_timeout.t
+++ b/t/04_timeout.t
@@ -2,7 +2,7 @@
## Test the timeout functionality
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/05_docs.t b/t/05_docs.t
index 9ee9cfc3..b48c64ad 100644
--- a/t/05_docs.t
+++ b/t/05_docs.t
@@ -2,7 +2,7 @@
## Some basic checks on the documentation
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/99_cleanup.t b/t/99_cleanup.t
index 18cb41b0..4b860b58 100644
--- a/t/99_cleanup.t
+++ b/t/99_cleanup.t
@@ -2,7 +2,7 @@
## Cleanup any mess we made
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
diff --git a/t/99_perlcritic.t b/t/99_perlcritic.t
index 23faa442..77838b71 100644
--- a/t/99_perlcritic.t
+++ b/t/99_perlcritic.t
@@ -3,7 +3,7 @@
## Run Perl::Critic against the source code and the tests
## This is highly customized, so take with a grain of salt
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Test::More;
diff --git a/t/99_pod.t b/t/99_pod.t
index f42dbc83..a9c0d7e1 100644
--- a/t/99_pod.t
+++ b/t/99_pod.t
@@ -2,7 +2,7 @@
## Check our Pod, requires Test::Pod
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Test::More;
diff --git a/t/99_spellcheck.t b/t/99_spellcheck.t
index e18f7a76..21b054eb 100644
--- a/t/99_spellcheck.t
+++ b/t/99_spellcheck.t
@@ -2,7 +2,7 @@
## Spellcheck as much as we can
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Test::More;
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 45230751..056b9572 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -2,7 +2,7 @@ package CP_Testing; ## -*- mode: CPerl; indent-tabs-mode: nil; cperl-indent-leve
## Common methods used by the other tests for check_postgres.pl
-use 5.008;
+use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
From 0beaaf0698314aa2230c2a1393019e735959de1e Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 15:00:00 -0400
Subject: [PATCH 263/272] Signature file for 2.26.0
---
check_postgres.pl.asc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/check_postgres.pl.asc b/check_postgres.pl.asc
index 496b12ee..de691862 100644
--- a/check_postgres.pl.asc
+++ b/check_postgres.pl.asc
@@ -1,6 +1,6 @@
-----BEGIN PGP SIGNATURE-----
-iEYEABEDAAYFAl44wNAACgkQvJuQZxSWSsgB3ACfcxwhdVa6P7CcPkERAElXpP6H
-LE4An24saOiaEefLxOlsMdenK6yLuJvr
-=NhBw
+iF0EABECAB0WIQQlKd9quPeUB+lERbS8m5BnFJZKyAUCZCsXMgAKCRC8m5BnFJZK
+yPU8AJ4xhTwuzxoO+0Kwl55rbBa2GYWmXACfWgFZLE2wUEFSOSVgzgtg3bjdefc=
+=43vZ
-----END PGP SIGNATURE-----
From 80dc9b593100005dcf0f4b4bc193544f517bdc20 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Mon, 3 Apr 2023 15:05:08 -0400
Subject: [PATCH 264/272] Restore mailing list information with new URIs
---
META.yml | 1 +
README.md | 18 ++++++++++++++++++
check_postgres.pl | 9 ++-------
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/META.yml b/META.yml
index e66e9b25..0cf8dcde 100644
--- a/META.yml
+++ b/META.yml
@@ -44,6 +44,7 @@ resources:
homepage : http://bucardo.org/check_postgres/
license : http://bucardo.org/check_postgres/
bugtracker : https://github.com/bucardo/check_postgres/issues
+ MailingList : https://bucardo.org/mailman/listinfo/check_postgres
Repository : git://bucardo.org/check_postgres.git
meta-spec:
diff --git a/README.md b/README.md
index e2b89f2c..b801c655 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,8 @@ file by:
cd postgres
perl ../check_postgres.pl --symlinks
+Then join the announce mailing list (see below)
+
Complete method
---------------
@@ -57,6 +59,22 @@ Development happens via git. You can check out the repository by doing:
https://github.com/bucardo/check_postgres
git clone https://github.com/bucardo/check_postgres.git
+
+Mailing lists
+-------------
+
+The final step should be to subscribe to the low volume check_postgres-announce
+mailing list, so you learn of new versions and important changes. Information
+on joining can be found at:
+
+https://bucardo.org/mailman/listinfo/check_postgres-announce
+
+General questions and development issues are discussed on the check_postgres list,
+which we recommend people join as well:
+
+https://bucardo.org/mailman/listinfo/check_postgres
+
+
COPYRIGHT
---------
diff --git a/check_postgres.pl b/check_postgres.pl
index 36de3fa5..953d74b5 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -11357,17 +11357,12 @@ =head1 MAILING LIST
Three mailing lists are available. For discussions about the program, bug reports,
feature requests, and commit notices, send email to check_postgres@bucardo.org
-L
+L
A low-volume list for announcement of new versions and important notices is the
'check_postgres-announce' list:
-L
-
-Source code changes (via git-commit) are sent to the
-'check_postgres-commit' list:
-
-L
+L
=head1 HISTORY
From cdbb4ab7b687cb0efd85af32d9edbf8c64673b65 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Tue, 4 Apr 2023 11:05:20 -0400
Subject: [PATCH 265/272] Apply new action "lockwait" from github issue #154
Slightly modified from original to use the pg_blocking_pids() function.
By github user miraclesvenni
---
check_postgres.pl | 78 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 953d74b5..161da673 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -163,6 +163,7 @@ package check_postgres;
'listening' => q{listening},
'locks-msg' => q{total "$1" locks: $2},
'locks-msg2' => q{total locks: $1},
+ 'lockwait-msg' => q{$1: $2($3) blocking $4($5) for $6 blocked statement "$7"},
'logfile-bad' => q{Invalid logfile "$1"},
'logfile-debug' => q{Final logfile: $1},
'logfile-dne' => q{logfile $1 does not exist!},
@@ -1902,6 +1903,7 @@ package check_postgres;
last_autovacuum => [0, 'Check the maximum time in seconds since any one table has been autovacuumed.'],
listener => [0, 'Checks for specific listeners.'],
locks => [0, 'Checks the number of locks.'],
+ lockwait => [0, 'Checks for blocking locks.'],
logfile => [1, 'Checks that the logfile is being written to correctly.'],
new_version_bc => [0, 'Checks if a newer version of Bucardo is available.'],
new_version_box => [0, 'Checks if a newer version of boxinfo is available.'],
@@ -2709,6 +2711,9 @@ sub finishup {
## Check number and type of locks
check_locks() if $action eq 'locks';
+## Check lock wait
+check_lockwait() if $action eq 'lockwait';
+
## Logfile is being written to
check_logfile() if $action eq 'logfile';
@@ -6177,6 +6182,63 @@ sub check_locks {
} ## end of check_locks
+sub check_lockwait {
+
+ ## Check lock wait
+ ## By default, checks all databases
+ ## Can check specific databases with include
+ ## Can ignore databases with exclude
+ ## Warning and critical is time
+ ## Example: --warning='1 min' --critical='2 min'
+
+ my ($warning, $critical) = validate_range
+ ({
+ type => 'time',
+ default_warning => '1 min',
+ default_critical => '2 min',
+ });
+
+ $SQL = qq{SELECT a.datname AS datname,
+ bl.pid AS blocked_pid,
+ a.usename AS blocked_user,
+ ka.pid AS blocking_pid,
+ ka.usename AS blocking_user,
+ round(extract (epoch from current_timestamp - a.query_start)) AS waited_sec,
+ a.query AS blocked_statement
+ FROM pg_catalog.pg_locks bl
+ JOIN pg_catalog.pg_stat_activity a ON a.pid = bl.pid
+ JOIN pg_catalog.pg_stat_activity ka ON (ka.pid = ANY(pg_blocking_pids(bl.pid)))
+ WHERE NOT bl.granted
+ };
+ my $info = run_command($SQL, { regex => qr{\w}, emptyok => 1 });
+ my $n = 0;
+ for $db (@{$info->{db}}) {
+ ROW: for my $r (@{$db->{slurp}}) {
+ my ($dbname,$blocked_pid,$blocked_user,$blocking_pid,$blocking_user,$waited_sec,$blocked_statement)
+ = ($r->{datname},$r->{blocked_pid}, $r->{blocked_user}, $r->{blocking_pid},
+ $r->{blocking_user},$r->{waited_sec},$r->{blocked_statement});
+
+ ## May be forcibly skipping this database via arguments
+ next ROW if skip_item($dbname);
+
+ my $msg = msg 'lockwait-msg',$dbname,$blocking_user,$blocking_pid,$blocked_user,$blocked_pid,pretty_time($waited_sec),$blocked_statement;
+ if (length $critical and $waited_sec >= $critical) {
+ add_critical $msg;
+ }
+ elsif (length $warning and $waited_sec >= $warning) {
+ add_warning $msg;
+ }
+ else {
+ add_ok $msg;
+ }
+ $n++;
+ }
+ }
+ add_ok 'No blocking locks' if ($n==0);
+ do_mrtg( {one => $n} ) if $MRTG;
+ return;
+
+} ## end of check_lockwait
sub check_logfile {
@@ -10493,6 +10555,22 @@ =head2 B
For MRTG output, returns the number of locks on the first line, and the name of the database on the fourth line.
+=head2 B
+
+(C) Check if there are blocking blocks and for how long. There is no
+need to run this more than once per database cluster. Databases can be filtered
+with the I<--include> and I<--exclude> options. See the L"BASIC FILTERING"> section
+for more details.
+
+The I<--warning> and I<--critical> options is time,
+which represent the time for which the lock has been blocking.
+
+Example 1: Warn if a lock has been blocking for more than a minute, critcal if for more than 2 minutes
+
+ check_postgres_lockwait --host=garrett --warning='1 min' --critical='2 min'
+
+For MRTG output, returns the number of blocked sessions.
+
=head2 B
(C) Ensures that the logfile is in the expected location and is being logged to.
From 88ec7e2e309617abd98265da6dd5eb1253b7f9d3 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane
Date: Tue, 4 Apr 2023 11:07:39 -0400
Subject: [PATCH 266/272] Attribution for last commit
---
check_postgres.pl | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index 161da673..b2dd92c5 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -11450,6 +11450,10 @@ =head1 HISTORY
=item B not yet released
+ Add new action "lockwait" showing details of blocked queries
+ (Github user miraclesvenni)
+ [Github issue #154]
+
Raise minimum version or Perl to 5.10.0
Allow commas in passwords via --dbpass for one-connection queries (Greg Sabino Mullane) [Github issue #133]
From 76b431637e8b4ab262aabf92754f278c2bac1b8b Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Mon, 7 Aug 2023 11:37:23 +0200
Subject: [PATCH 267/272] Run regression tests in GitHub action
Ignore t/02_same_schema, it's currently broken
---
.github/workflows/regression.yml | 41 ++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 .github/workflows/regression.yml
diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml
new file mode 100644
index 00000000..3810cc53
--- /dev/null
+++ b/.github/workflows/regression.yml
@@ -0,0 +1,41 @@
+name: Build
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ defaults:
+ run:
+ shell: sh
+
+ strategy:
+ matrix:
+ pgversion:
+ - 16
+ - 15
+ - 14
+ - 13
+ - 12
+ - 11
+ - 10
+
+ env:
+ PGVERSION: ${{ matrix.pgversion }}
+
+ steps:
+ - name: checkout
+ uses: actions/checkout@v3
+
+ - name: install pg
+ run: |
+ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -v $PGVERSION -p -i
+ sudo apt-get install -f libdbd-pg-perl
+ sudo -u postgres createuser -s "$USER"
+
+ - name: test
+ run: |
+ # 02_same_schema test currently broken
+ rm -fv t/02_same_schema.t
+ LC_ALL=C PERL_USE_UNSAFE_INC=1 PGBINDIR=/usr/lib/postgresql/$PGVERSION/bin prove t
From f6bc7f09cbada0c564c43b6e575d14d775cd2815 Mon Sep 17 00:00:00 2001
From: Christoph Berg
Date: Mon, 7 Aug 2023 11:52:22 +0200
Subject: [PATCH 268/272] Document partman_premake
---
check_postgres.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/check_postgres.pl b/check_postgres.pl
index b2dd92c5..c3f14093 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -10646,6 +10646,12 @@ =head2 B
See: L for more information).
See also the information on the C<--get_method> option.
+=head2 B
+
+(C) Checks if all partitions that
+B's maintenance routine should have created are actually present.
+Monthly and daily intervals are supported.
+
=head2 B
=head2 B
From 1066477d38fe362285529ba62e55855af0d2c07f Mon Sep 17 00:00:00 2001
From: Per Modin
Date: Wed, 9 Aug 2023 13:10:53 +0100
Subject: [PATCH 269/272] doc: Set html title with pod2html for `make html`
Pass title argument to pod2html, instead of editing the file afterwards.
This helps avoiding broken tags in the resulting document.
---
Makefile.PL | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 729cc1a4..607a71cc 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -105,10 +105,9 @@ sub clean { ## no critic (RequireArgUnpacking)
$string .= qq{\t@ gpg --verify check_postgres.pl.asc\n};
$string .= qq{\n\nhtml : \n\t};
$string .= <<'EOM';
- pod2html check_postgres.pl > check_postgres.pl.html
+ pod2html --title check_postgres.pl check_postgres.pl > check_postgres.pl.html
@ perl -pi -e "s///" check_postgres.pl.html
@ perl -pi -e "s~ git clone.*~ git clone git://bucardo.org/check_postgres.git
~" check_postgres.pl.html
- @ perl -pi -e "s~ ## Create all symlinks
- check_postgres.pl --symlinks
+## Create all symlinks
+check_postgres.pl --symlinks
- ## Check connection to Postgres database 'pluto':
- check_postgres.pl --action=connection --db=pluto
+## Check connection to Postgres database 'pluto':
+check_postgres.pl --action=connection --db=pluto
- ## Same things, but using the symlink
- check_postgres_connection --db=pluto
+## Same things, but using the symlink
+check_postgres_connection --db=pluto
- ## Warn if > 100 locks, critical if > 200, or > 20 exclusive
- check_postgres_locks --warning=100 --critical="total=200:exclusive=20"
+## Warn if > 100 locks, critical if > 200, or > 20 exclusive
+check_postgres_locks --warning=100 --critical="total=200:exclusive=20"
- ## Show the current number of idle connections on port 6543:
- check_postgres_txn_idle --port=6543 --output=simple
+## Show the current number of idle connections on port 6543:
+check_postgres_txn_idle --port=6543 --output=simple
- ## There are many other actions and options, please keep reading.
+## There are many other actions and options, please keep reading.
- The latest news and documentation can always be found at:
- https://bucardo.org/check_postgres/
+The latest news and documentation can always be found at:
+https://bucardo.org/check_postgres/
The simple output is simply a truncated version of the MRTG one, and simply returns the first number and nothing else. This is very useful when you just want to check the state of something, regardless of any threshold. You can transform the numeric output by appending KB, MB, GB, TB, or EB to the output argument, for example:
- --output=simple,MB
+--output=simple,MB
Examples:
- --host=a,b --port=5433 --db=c
- Connects twice to port 5433, using database c, to hosts a and b: a-5433-c b-5433-c
+--host=a,b --port=5433 --db=c
+Connects twice to port 5433, using database c, to hosts a and b: a-5433-c b-5433-c
- --host=a,b --port=5433 --db=c,d
- Connects four times: a-5433-c a-5433-d b-5433-c b-5433-d
+--host=a,b --port=5433 --db=c,d
+Connects four times: a-5433-c a-5433-d b-5433-c b-5433-d
- --host=a,b --host=foo --port=1234 --port=5433 --db=e,f
- Connects six times: a-1234-e a-1234-f b-1234-e b-1234-f foo-5433-e foo-5433-f
+--host=a,b --host=foo --port=1234 --port=5433 --db=e,f
+Connects six times: a-1234-e a-1234-f b-1234-e b-1234-f foo-5433-e foo-5433-f
- --host=a,b --host=x --port=5432,5433 --dbuser=alice --dbuser=bob -db=baz
- Connects three times: a-5432-alice-baz b-5433-alice-baz x-5433-bob-baz
+--host=a,b --host=x --port=5432,5433 --dbuser=alice --dbuser=bob -db=baz
+Connects three times: a-5432-alice-baz b-5433-alice-baz x-5433-bob-baz
- --dbservice="foo" --port=5433
- Connects using the named service 'foo' in the pg_service.conf file, but overrides the port
+--dbservice="foo" --port=5433
+Connects using the named service 'foo' in the pg_service.conf file, but overrides the port
Example:
- postgres@db$./check_postgres.pl --action=version --warning=8.1 --datadir /var/lib/postgresql/8.3/main/ --assume-standby-mode
- POSTGRES_VERSION OK: Server in standby mode | time=0.00
+postgres@db$./check_postgres.pl --action=version --warning=8.1 --datadir /var/lib/postgresql/8.3/main/ --assume-standby-mode
+POSTGRES_VERSION OK: Server in standby mode | time=0.00
Example:
- postgres@db$./check_postgres.pl --action=checkpoint --datadir /var/lib/postgresql/8.3/main/ --assume-prod
- POSTGRES_CHECKPOINT OK: Last checkpoint was 72 seconds ago | age=72;;300 mode=MASTER
+postgres@db$./check_postgres.pl --action=checkpoint --datadir /var/lib/postgresql/8.3/main/ --assume-prod
+POSTGRES_CHECKPOINT OK: Last checkpoint was 72 seconds ago | age=72;;300 mode=MASTER
Allows specification of the method used to fetch information for the new_version_cp
, new_version_pg
, new_version_bc
, new_version_box
, and new_version_tnm
checks. The following programs are tried, in order, to grab the information from the web: GET, wget, fetch, curl, lynx, links. To force the use of just one (and thus remove the overhead of trying all the others until one of those works), enter one of the names as the argument to get_method. For example, a BSD box might enter the following line in their .check_postgresrc
file:
get_method=fetch
+get_method=fetch
The action to be run is selected using the --action flag, or by using a symlink to the main file that contains the name of the action inside of it. For example, to run the action "timesync", you may either issue:
- check_postgres.pl --action=timesync
+check_postgres.pl --action=timesync
or use a program named:
- check_postgres_timesync
+check_postgres_timesync
All the symlinks are created for you in the current directory if use the option --symlinks:
- perl check_postgres.pl --symlinks
+perl check_postgres.pl --symlinks
If the file name already exists, it will not be overwritten. If the file exists and is a symlink, you can force it to overwrite by using "--action=build_symlinks_force".
@@ -452,19 +454,19 @@To avoid running as a database superuser, a wrapper function around pg_ls_dir()
should be defined as a superuser with SECURITY DEFINER, and the --lsfunc option used. This example function, if defined by a superuser, will allow the script to connect as a normal user nagios with --lsfunc=ls_archive_status_dir
BEGIN;
- CREATE FUNCTION ls_archive_status_dir()
- RETURNS SETOF TEXT
- AS $$ SELECT pg_ls_dir('pg_xlog/archive_status') $$
- LANGUAGE SQL
- SECURITY DEFINER;
- REVOKE ALL ON FUNCTION ls_archive_status_dir() FROM PUBLIC;
- GRANT EXECUTE ON FUNCTION ls_archive_status_dir() to nagios;
- COMMIT;
+BEGIN;
+CREATE FUNCTION ls_archive_status_dir()
+ RETURNS SETOF TEXT
+ AS $$ SELECT pg_ls_dir('pg_xlog/archive_status') $$
+ LANGUAGE SQL
+ SECURITY DEFINER;
+REVOKE ALL ON FUNCTION ls_archive_status_dir() FROM PUBLIC;
+GRANT EXECUTE ON FUNCTION ls_archive_status_dir() to nagios;
+COMMIT;
Example 1: Check that the number of ready WAL files is 10 or less on host "pluto", using a wrapper function ls_archive_status_dir
to avoid the need for superuser permissions
check_postgres_archive_ready --host=pluto --critical=10 --lsfunc=ls_archive_status_dir
+check_postgres_archive_ready --host=pluto --critical=10 --lsfunc=ls_archive_status_dir
For MRTG output, reports the number of ready WAL files on line 1.
@@ -474,7 +476,7 @@Example 1: Give a warning when any databases on port 5432 are above 97%
- check_postgres_autovac_freeze --port=5432 --warning="97%"
+check_postgres_autovac_freeze --port=5432 --warning="97%"
For MRTG output, the highest overall percentage is reported on the first line, and the highest age is reported on the second line. All databases which have the percentage from the first line are reported on the fourth line, separated by a pipe symbol.
@@ -486,19 +488,19 @@Example 1: Give a warning when the number of connections on host quirm reaches 120, and a critical if it reaches 150.
- check_postgres_backends --host=quirm --warning=120 --critical=150
+check_postgres_backends --host=quirm --warning=120 --critical=150
Example 2: Give a critical when we reach 75% of our max_connections setting on hosts lancre or lancre2.
- check_postgres_backends --warning='75%' --critical='75%' --host=lancre,lancre2
+check_postgres_backends --warning='75%' --critical='75%' --host=lancre,lancre2
Example 3: Give a warning when there are only 10 more connection slots left on host plasmid, and a critical when we have only 5 left.
- check_postgres_backends --warning=-10 --critical=-5 --host=plasmid
+check_postgres_backends --warning=-10 --critical=-5 --host=plasmid
Example 4: Check all databases except those with "test" in their name, but allow ones that are named "pg_greatest". Connect as port 5432 on the first two hosts, and as port 5433 on the third one. We want to always throw a critical when we reach 30 or more connections.
- check_postgres_backends --dbhost=hong,kong --dbhost=fooey --dbport=5432 --dbport=5433 --warning=30 --critical=30 --exclude="~test" --include="pg_greatest,~prod"
+check_postgres_backends --dbhost=hong,kong --dbhost=fooey --dbport=5432 --dbport=5433 --warning=30 --critical=30 --exclude="~test" --include="pg_greatest,~prod"
For MRTG output, the number of connections is reported on the first line, and the fourth line gives the name of the database, plus the current maximum_connections. If more than one database has been queried, the one with the highest number of connections is output.
@@ -518,23 +520,23 @@Example 1: Warn if any table on port 5432 is over 100 MB bloated, and critical if over 200 MB
- check_postgres_bloat --port=5432 --warning='100 M' --critical='200 M'
+check_postgres_bloat --port=5432 --warning='100 M' --critical='200 M'
Example 2: Give a critical if table 'orders' on host 'sami' has more than 10 megs of bloat
- check_postgres_bloat --host=sami --include=orders --critical='10 MB'
+check_postgres_bloat --host=sami --include=orders --critical='10 MB'
Example 3: Give a critical if table 'q4' on database 'sales' is over 50% bloated
- check_postgres_bloat --db=sales --include=q4 --critical='50%'
+check_postgres_bloat --db=sales --include=q4 --critical='50%'
Example 4: Give a critical any table is over 20% bloated and has over 150 MB of bloat:
- check_postgres_bloat --port=5432 --critical='20% and 150 M'
+check_postgres_bloat --port=5432 --critical='20% and 150 M'
Example 5: Give a critical any table is over 40% bloated or has over 500 MB of bloat:
- check_postgres_bloat --port=5432 --warning='500 M or 40%'
+check_postgres_bloat --port=5432 --warning='500 M or 40%'
For MRTG output, the first line gives the highest number of wasted bytes for the tables, and the second line gives the highest number of wasted bytes for the indexes. The fourth line gives the database name, table name, and index name information. If you want to output the bloat ratio instead (how many times larger the relation is compared to how large it should be), just pass in --mrtg=ratio
.
Example 1: Find the initial identifier
- check_postgres_cluster_id --critical=0 --datadir=/var//lib/postgresql/9.0/main
+check_postgres_cluster_id --critical=0 --datadir=/var//lib/postgresql/9.0/main
Example 2: Make sure the cluster is the same and warn if not, using the result from above.
- check_postgres_cluster_id --critical=5633695740047915135
+check_postgres_cluster_id --critical=5633695740047915135
For MRTG output, returns a 1 or 0 indicating success of failure of the identifier to match. A identifier must be provided as the --mrtg
argument. The fourth line always gives the current identifier.
Example: Warn if any database on host flagg is less than 90% in commitratio, and critical if less then 80%.
- check_postgres_database_commitratio --host=flagg --warning='90%' --critical='80%'
+check_postgres_database_commitratio --host=flagg --warning='90%' --critical='80%'
For MRTG output, returns the percentage of the database with the smallest commitratio on the first line, and the name of the database on the fourth line.
@@ -598,16 +600,16 @@Example 1: Warn if any relation over 100 pages is named "rad", put the number of pages inside the performance data section.
- check_postgres_custom_query --valtype=string -w "rad" --query=
- "SELECT relname AS result, relpages AS pages FROM pg_class WHERE relpages > 100"
+check_postgres_custom_query --valtype=string -w "rad" --query=
+ "SELECT relname AS result, relpages AS pages FROM pg_class WHERE relpages > 100"
Example 2: Give a critical if the "foobar" function returns a number over 5MB:
- check_postgres_custom_query --critical='5MB'--valtype=size --query="SELECT foobar() AS result"
+check_postgres_custom_query --critical='5MB'--valtype=size --query="SELECT foobar() AS result"
Example 2: Warn if the function "snazzo" returns less than 42:
- check_postgres_custom_query --critical=42 --query="SELECT snazzo() AS result" --reverse
+check_postgres_custom_query --critical=42 --query="SELECT snazzo() AS result" --reverse
If you come up with a useful custom_query, consider sending in a patch to this program to make it into a standard action that other people can use.
@@ -621,15 +623,15 @@Example 1: Warn if any database on host flagg is over 1 TB in size, and critical if over 1.1 TB.
- check_postgres_database_size --host=flagg --warning='1 TB' --critical='1.1 t'
+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.
- check_postgres_database_size --port=5432 --include=template1 --warning='10MB' --critical='10MB'
+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
- check_postgres_database_size --host=tardis --includeuser=tom --warning='5 GB' --critical='10 GB'
+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.
@@ -761,13 +763,13 @@Example 1: Grab the stats for a database named "products" on host "willow":
- check_postgres_dbstats --dbhost willow --dbname products
+check_postgres_dbstats --dbhost willow --dbname products
The output returned will be like this (all on one line, not wrapped):
- backends:82 commits:58374408 rollbacks:1651 read:268435543 hit:2920381758 idxscan:310931294 idxtupread:2777040927
- idxtupfetch:1840241349 idxblksread:62860110 idxblkshit:1107812216 seqscan:5085305 seqtupread:5370500520
- ret:0 fetch:0 ins:0 upd:0 del:0 dbname:willow
+backends:82 commits:58374408 rollbacks:1651 read:268435543 hit:2920381758 idxscan:310931294 idxtupread:2777040927
+idxtupfetch:1840241349 idxblksread:62860110 idxblkshit:1107812216 seqscan:5085305 seqtupread:5370500520
+ret:0 fetch:0 ins:0 upd:0 del:0 dbname:willow
Example 1: Make sure that there are no disabled triggers
- check_postgres_disabled_triggers
+check_postgres_disabled_triggers
For MRTG output, returns the number of disabled triggers on the first line.
@@ -797,19 +799,19 @@Example 1: Make sure that no file system is over 90% for the database on port 5432.
- check_postgres_disk_space --port=5432 --warning='90%' --critical='90%'
+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)
- check_postgres_disk_space --port=5432 --warning='10 GB' --critical='11 GB' --include="~^/dev/sda"
+check_postgres_disk_space --port=5432 --warning='10 GB' --critical='11 GB' --include="~^/dev/sda"
Example 4: Make sure that no file system is both over 50% and has over 15 GB
- check_postgres_disk_space --critical='50% and 15 GB'
+check_postgres_disk_space --critical='50% and 15 GB'
Example 5: Issue a warning if any file system is either over 70% full or has more than 1T
- check_postgres_disk_space --warning='1T or 75'
+check_postgres_disk_space --warning='1T or 75'
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.
@@ -819,7 +821,7 @@Example 1: Give a warning when our cluster has used up 76% of the free-space pageslots, with pg_freespacemap installed in database robert
- check_postgres_fsm_pages --dbname=robert --warning="76%"
+check_postgres_fsm_pages --dbname=robert --warning="76%"
While you need to pass in the name of the database where pg_freespacemap is installed, 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.
@@ -831,7 +833,7 @@Example 1: Give a warning when our cluster has used up 80% of the free-space relations, with pg_freespacemap installed in database dylan
- check_postgres_fsm_relations --dbname=dylan --warning="75%"
+check_postgres_fsm_relations --dbname=dylan --warning="75%"
While you need to pass in the name of the database where pg_freespacemap is installed, 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.
@@ -845,7 +847,7 @@Example: Warn if any database on host flagg is less than 90% in hitratio, and critical if less then 80%.
- check_postgres_hitratio --host=flagg --warning='90%' --critical='80%'
+check_postgres_hitratio --host=flagg --warning='90%' --critical='80%'
For MRTG output, returns the percentage of the database with the smallest hitratio on the first line, and the name of the database on the fourth line.
@@ -861,15 +863,15 @@Example 1: Warn a database with a local replica on port 5433 is behind on any xlog replay at all
- check_hot_standby_delay --dbport=5432,5433 --warning='1'
+check_hot_standby_delay --dbport=5432,5433 --warning='1'
Example 2: Give a critical if the last transaction replica1 receives is more than 10 minutes ago
- check_hot_standby_delay --dbhost=master,replica1 --critical='10 min'
+check_hot_standby_delay --dbhost=master,replica1 --critical='10 min'
Example 3: Allow replica1 to be 1 WAL segment behind, if the master is momentarily seeing more activity than the streaming replication connection can handle, or 10 minutes behind, if the master is seeing very little activity and not processing any transactions, but not both, which would indicate a lasting problem with the replication connection.
- check_hot_standby_delay --dbhost=master,replica1 --warning='1048576 and 2 min' --critical='16777216 and 10 min'
+check_hot_standby_delay --dbhost=master,replica1 --warning='1048576 and 2 min' --critical='16777216 and 10 min'
Example 1: Give a critical if any table is larger than 600MB on host burrick.
- check_postgres_table_size --critical='600 MB' --warning='600 MB' --host=burrick
+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.
- check_postgres_table_size --host=burrick --warning='4 GB' --critical='4.5 GB' --include=products
+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.
- check_postgres_index_size --port=5432 --excludeuser=postgres -w 500MB -c 600MB
+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.
@@ -929,11 +931,11 @@Example 1: Warn if any table has not been vacuumed in 3 days, and give a critical at a week, for host wormwood
- check_postgres_last_vacuum --host=wormwood --warning='3d' --critical='7d'
+check_postgres_last_vacuum --host=wormwood --warning='3d' --critical='7d'
Example 2: Same as above, but skip tables belonging to the users 'eve' or 'mallory'
- check_postgres_last_vacuum --host=wormwood --warning='3d' --critical='7d' --excludeuser=eve,mallory
+check_postgres_last_vacuum --host=wormwood --warning='3d' --critical='7d' --excludeuser=eve,mallory
For MRTG output, returns (on the first line) the LEAST amount of time in seconds since a table was last vacuumed or analyzed. The fourth line returns the name of the database and name of the table.
@@ -943,11 +945,11 @@Example 1: Give a warning if nobody is listening for the string bucardo_mcp_ping on ports 5555 and 5556
- check_postgres_listener --port=5555,5556 --warning=bucardo_mcp_ping
+check_postgres_listener --port=5555,5556 --warning=bucardo_mcp_ping
Example 2: Give a critical if there are no active LISTEN requests matching 'grimm' on database oskar
- check_postgres_listener --db oskar --critical=~grimm
+check_postgres_listener --db oskar --critical=~grimm
For MRTG output, returns a 1 or a 0 on the first, indicating success or failure. The name of the notice must be provided via the --mrtg option.
@@ -959,25 +961,37 @@Example 1: Warn if the number of locks is 100 or more, and critical if 200 or more, on host garrett
- check_postgres_locks --host=garrett --warning=100 --critical=200
+check_postgres_locks --host=garrett --warning=100 --critical=200
Example 2: On the host artemus, warn if 200 or more locks exist, and give a critical if over 250 total locks exist, or if over 20 exclusive locks exist, or if over 5 connections are waiting for a lock.
- check_postgres_locks --host=artemus --warning=200 --critical="total=250:waiting=5:exclusive=20"
+check_postgres_locks --host=artemus --warning=200 --critical="total=250:waiting=5:exclusive=20"
For MRTG output, returns the number of locks on the first line, and the name of the database on the fourth line.
+(symlink: check_postgres_lockwait
) Check if there are blocking blocks and for how long. There is no need to run this more than once per database cluster. Databases can be filtered with the --include and --exclude options. See the "BASIC FILTERING" section for more details.
The --warning and --critical options is time, which represent the time for which the lock has been blocking.
+ +Example 1: Warn if a lock has been blocking for more than a minute, critcal if for more than 2 minutes
+ +check_postgres_lockwait --host=garrett --warning='1 min' --critical='2 min'
+
+For MRTG output, returns the number of blocked sessions.
+(symlink: check_postgres_logfile
) Ensures that the logfile is in the expected location and is being logged to. This action issues a command that throws an error on each database it is checking, and ensures that the message shows up in the logs. It scans the various log_* settings inside of Postgres to figure out where the logs should be. If you are using syslog, it does a rough (but not foolproof) scan of /etc/syslog.conf. Alternatively, you can provide the name of the logfile with the --logfile option. This is especially useful if the logs have a custom rotation scheme driven be an external program. The --logfile option supports the following escape characters: %Y %m %d %H
, which represent the current year, month, date, and hour respectively. An error is always reported as critical unless the warning option has been passed in as a non-zero value. Other than that specific usage, the --warning
and --critical
options should not be used.
Example 1: On port 5432, ensure the logfile is being written to the file /home/greg/pg8.2.log
- check_postgres_logfile --port=5432 --logfile=/home/greg/pg8.2.log
+check_postgres_logfile --port=5432 --logfile=/home/greg/pg8.2.log
Example 2: Same as above, but raise a warning, not a critical
- check_postgres_logfile --port=5432 --logfile=/home/greg/pg8.2.log -w 1
+check_postgres_logfile --port=5432 --logfile=/home/greg/pg8.2.log -w 1
For MRTG output, returns a 1 or 0 on the first line, indicating success or failure. In case of a failure, the fourth line will provide more detail on the failure encountered.
@@ -1001,6 +1015,10 @@(symlink: check_postgres_new_version_tnm
) Checks if a newer version of the tail_n_mail program is available. The current version is obtained by running tail_n_mail --version
. If a major upgrade is available, a warning is returned. If a revision upgrade is available, a critical is returned. (tail_n_mail is a log monitoring tool that can send mail when interesting events appear in your Postgres logs. See: https://bucardo.org/tail_n_mail/ for more information). See also the information on the --get_method
option.
(symlink: check_postgres_partman_premake
) Checks if all partitions that pg_parman's maintenance routine should have created are actually present. Monthly and daily intervals are supported.
Example 1: Give a warning when the number of connections on host quirm reaches 120, and a critical if it reaches 150.
- check_postgres_pgbouncer_backends --host=quirm --warning=120 --critical=150 -p 6432 -u pgbouncer
+check_postgres_pgbouncer_backends --host=quirm --warning=120 --critical=150 -p 6432 -u pgbouncer
Example 2: Give a critical when we reach 75% of our max_connections setting on hosts lancre or lancre2.
- check_postgres_pgbouncer_backends --warning='75%' --critical='75%' --host=lancre,lancre2 -p 6432 -u pgbouncer
+check_postgres_pgbouncer_backends --warning='75%' --critical='75%' --host=lancre,lancre2 -p 6432 -u pgbouncer
Example 3: Give a warning when there are only 10 more connection slots left on host plasmid, and a critical when we have only 5 left.
- check_postgres_pgbouncer_backends --warning=-10 --critical=-5 --host=plasmid -p 6432 -u pgbouncer
+check_postgres_pgbouncer_backends --warning=-10 --critical=-5 --host=plasmid -p 6432 -u pgbouncer
For MRTG output, the number of connections is reported on the first line, and the fourth line gives the name of the database, plus the current max_client_conn. If more than one database has been queried, the one with the highest number of connections is output.
@@ -1049,11 +1067,11 @@Example 1: Find the initial checksum for pgbouncer configuration on port 6432 using the default user (usually postgres)
- check_postgres_pgbouncer_checksum --port=6432 --critical=0
+check_postgres_pgbouncer_checksum --port=6432 --critical=0
Example 2: Make sure no settings have changed and warn if so, using the checksum from above.
- check_postgres_pgbouncer_checksum --port=6432 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
+check_postgres_pgbouncer_checksum --port=6432 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A checksum must be provided as the --mrtg
argument. The fourth line always gives the current checksum.
Example 1: Give a critical if any transaction has been open for more than 10 minutes:
- check_postgres_pgbouncer_maxwait -p 6432 -u pgbouncer --critical='10 minutes'
+check_postgres_pgbouncer_maxwait -p 6432 -u pgbouncer --critical='10 minutes'
For MRTG output, returns the maximum time in seconds a transaction has been open on the first line. The fourth line gives the name of the database.
@@ -1077,15 +1095,15 @@Example 1: Give a critical when any jobs executed in the last day have failed.
- check_postgres_pgagent_jobs --critical=1d
+check_postgres_pgagent_jobs --critical=1d
Example 2: Give a warning when any jobs executed in the last week have failed.
- check_postgres_pgagent_jobs --warning=7d
+check_postgres_pgagent_jobs --warning=7d
Example 3: Give a critical for jobs that have failed in the last 2 hours and a warning for jobs that have failed in the last 4 hours:
- check_postgres_pgagent_jobs --critical=2h --warning=4h
+check_postgres_pgagent_jobs --critical=2h --warning=4h
Example 1: Give a warning on detecting any prepared transactions:
- check_postgres_prepared_txns -w 0
+check_postgres_prepared_txns -w 0
Example 2: Give a critical if any prepared transaction has been open longer than 10 seconds, but allow up to 360 seconds for the database 'shrike':
- check_postgres_prepared_txns --critical=10 --exclude=shrike
- check_postgres_prepared_txns --critical=360 --include=shrike
+check_postgres_prepared_txns --critical=10 --exclude=shrike
+check_postgres_prepared_txns --critical=360 --include=shrike
For MRTG output, returns the number of seconds the oldest transaction has been open as the first line, and which database is came from as the final line.
@@ -1108,7 +1126,7 @@Example 1: Give a critical if the function named "speedtest" fails to run in 10 seconds or less.
- check_postgres_query_runtime --queryname='speedtest()' --critical=10 --warning=10
+check_postgres_query_runtime --queryname='speedtest()' --critical=10 --warning=10
For MRTG output, reports the time in seconds for the query to complete on the first line. The fourth line lists the database.
@@ -1122,15 +1140,15 @@Example 1: Give a warning if any query has been running longer than 3 minutes, and a critical if longer than 5 minutes.
- check_postgres_query_time --port=5432 --warning='3 minutes' --critical='5 minutes'
+check_postgres_query_time --port=5432 --warning='3 minutes' --critical='5 minutes'
Example 2: Using default values (2 and 5 minutes), check all databases except those starting with 'template'.
- check_postgres_query_time --port=5432 --exclude=~^template
+check_postgres_query_time --port=5432 --exclude=~^template
Example 3: Warn if user 'don' has a query running over 20 seconds
- check_postgres_query_time --port=5432 --includeuser=don --warning=20s
+check_postgres_query_time --port=5432 --includeuser=don --warning=20s
For MRTG output, returns the length in seconds of the longest running query on the first line. The fourth line gives the name of the database.
@@ -1144,13 +1162,13 @@Example 1: Slony is replicating a table named 'orders' from host 'alpha' to host 'beta', in the database 'sales'. The primary key of the table is named id, and we are going to test the row with an id of 3 (which is historical and never changed). There is a column named 'salesrep' that we are going to toggle from a value of 'slon' to 'nols' to check on the replication. We want to throw a warning if the replication does not happen within 10 seconds.
- check_postgres_replicate_row --host=alpha --dbname=sales --host=beta
- --dbname=sales --warning=10 --repinfo=orders,id,3,salesrep,slon,nols
+check_postgres_replicate_row --host=alpha --dbname=sales --host=beta
+--dbname=sales --warning=10 --repinfo=orders,id,3,salesrep,slon,nols
Example 2: Bucardo is replicating a table named 'receipt' from host 'green' to hosts 'red', 'blue', and 'yellow'. The database for both sides is 'public'. The slave databases are running on port 5455. The primary key is named 'receipt_id', the row we want to use has a value of 9, and the column we want to change for the test is called 'zone'. We'll toggle between 'north' and 'south' for the value of this column, and throw a critical if the change is not on all three slaves within 5 seconds.
- check_postgres_replicate_row --host=green --port=5455 --host=red,blue,yellow
- --critical=5 --repinfo=receipt,receipt_id,9,zone,north,south
+check_postgres_replicate_row --host=green --port=5455 --host=red,blue,yellow
+ --critical=5 --repinfo=receipt,receipt_id,9,zone,north,south
For MRTG output, returns on the first line the time in seconds the replication takes to finish. The maximum time is set to 4 minutes 30 seconds: if no replication has taken place in that long a time, an error is thrown.
@@ -1160,7 +1178,7 @@Warning and critical are total bytes retained for the slot. E.g:
- check_postgres_replication_slots --port=5432 --host=yellow -warning=32M -critical=64M
+check_postgres_replication_slots --port=5432 --host=yellow -warning=32M -critical=64M
Specific named slots can be monitored using --include/--exclude
@@ -1232,32 +1250,32 @@Example 1: Verify that two databases on hosts star and line are the same:
- check_postgres_same_schema --dbhost=star,line
+check_postgres_same_schema --dbhost=star,line
Example 2: Same as before, but exclude any triggers with "slony" in their name
- check_postgres_same_schema --dbhost=star,line --filter="notrigger=slony"
+check_postgres_same_schema --dbhost=star,line --filter="notrigger=slony"
Example 3: Same as before, but also exclude all indexes
- check_postgres_same_schema --dbhost=star,line --filter="notrigger=slony noindexes"
+check_postgres_same_schema --dbhost=star,line --filter="notrigger=slony noindexes"
Example 4: Check differences for the database "battlestar" on different ports
- check_postgres_same_schema --dbname=battlestar --dbport=5432,5544
+check_postgres_same_schema --dbname=battlestar --dbport=5432,5544
Example 5: Create a daily and weekly snapshot file
- check_postgres_same_schema --dbname=cylon --suffix=daily
- check_postgres_same_schema --dbname=cylon --suffix=weekly
+check_postgres_same_schema --dbname=cylon --suffix=daily
+check_postgres_same_schema --dbname=cylon --suffix=weekly
Example 6: Run a historical comparison, then replace the file
- check_postgres_same_schema --dbname=cylon --suffix=daily --replace
+check_postgres_same_schema --dbname=cylon --suffix=daily --replace
Example 7: Verify that two databases on hosts star and line are the same, excluding value data (i.e. sequence last_val):
- check_postgres_same_schema --dbhost=star,line --assume-async
+check_postgres_same_schema --dbhost=star,line --assume-async
Example 1: Give a warning if any sequences are approaching 95% full.
- check_postgres_sequence --dbport=5432 --warning=95%
+check_postgres_sequence --dbport=5432 --warning=95%
Example 2: Check that the sequence named "orders_id_seq" is not more than half full.
- check_postgres_sequence --dbport=5432 --critical=50% --include=orders_id_seq
+check_postgres_sequence --dbport=5432 --critical=50% --include=orders_id_seq
Example 1: Find the initial checksum for the database on port 5555 using the default user (usually postgres)
- check_postgres_settings_checksum --port=5555 --critical=0
+check_postgres_settings_checksum --port=5555 --critical=0
Example 2: Make sure no settings have changed and warn if so, using the checksum from above.
- check_postgres_settings_checksum --port=5555 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
+check_postgres_settings_checksum --port=5555 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A checksum must be provided as the --mrtg
argument. The fourth line always gives the current checksum.
Example 1: Give a warning if any Slony is lagged by more than 20 seconds
- check_postgres_slony_status --warning 20
+check_postgres_slony_status --warning 20
Example 2: Give a critical if Slony, installed under the schema "_slony", is over 10 minutes lagged
- check_postgres_slony_status --schema=_slony --critical=600
+check_postgres_slony_status --schema=_slony --critical=600
Example 1: Check that databases on hosts ankh, morpork, and klatch are no more than 3 seconds off from the local time:
- check_postgres_timesync --host=ankh,morpork,klatch --critical=3
+check_postgres_timesync --host=ankh,morpork,klatch --critical=3
For MRTG output, returns one the first line the number of seconds difference between the local time and the database time. The fourth line returns the name of the database.
@@ -1329,15 +1347,15 @@Example 1: Give a warning if any connection has been idle in transaction for more than 15 seconds:
- check_postgres_txn_idle --port=5432 --warning='15 seconds'
+check_postgres_txn_idle --port=5432 --warning='15 seconds'
Example 2: Give a warning if there are 50 or more transactions
- check_postgres_txn_idle --port=5432 --warning='+50'
+check_postgres_txn_idle --port=5432 --warning='+50'
Example 3: Give a critical if 5 or more connections have been idle in transaction for more than 10 seconds:
- check_postgres_txn_idle --port=5432 --critical='5 for 10 seconds'
+check_postgres_txn_idle --port=5432 --critical='5 for 10 seconds'
For MRTG output, returns the time in seconds the longest idle transaction has been running. The fourth line returns the name of the database and other information about the longest transaction.
@@ -1351,11 +1369,11 @@Example 1: Give a critical if any transaction has been open for more than 10 minutes:
- check_postgres_txn_time --port=5432 --critical='10 minutes'
+check_postgres_txn_time --port=5432 --critical='10 minutes'
Example 1: Warn if user 'warehouse' has a transaction open over 30 seconds
- check_postgres_txn_time --port-5432 --warning=30s --includeuser=warehouse
+check_postgres_txn_time --port-5432 --warning=30s --includeuser=warehouse
For MRTG output, returns the maximum time in seconds a transaction has been open on the first line. The fourth line gives the name of the database.
@@ -1367,11 +1385,11 @@Example 1: Check the default values for the localhost database
- check_postgres_txn_wraparound --host=localhost
+check_postgres_txn_wraparound --host=localhost
Example 2: Check port 6000 and give a critical when 1.7 billion transactions are hit:
- check_postgres_txn_wraparound --port=6000 --critical=1_700_000_000
+check_postgres_txn_wraparound --port=6000 --critical=1_700_000_000
For MRTG output, returns the highest number of transactions for all databases on line one, while line 4 indicates which database it is.
@@ -1381,11 +1399,11 @@Example 1: Give a warning if the database on port 5678 is not version 8.4.10:
- check_postgres_version --port=5678 -w=8.4.10
+check_postgres_version --port=5678 -w=8.4.10
Example 2: Give a warning if any databases on hosts valley,grain, or sunshine is not 8.3:
- check_postgres_version -H valley,grain,sunshine --critical=8.3
+check_postgres_version -H valley,grain,sunshine --critical=8.3
For MRTG output, reports a 1 or a 0 indicating success or failure on the first line. The fourth line indicates the current version. The version must be provided via the --mrtg
option.
To avoid connecting as a database superuser, a wrapper function around pg_ls_dir()
should be defined as a superuser with SECURITY DEFINER, and the --lsfunc option used. This example function, if defined by a superuser, will allow the script to connect as a normal user nagios with --lsfunc=ls_xlog_dir
BEGIN;
- CREATE FUNCTION ls_xlog_dir()
- RETURNS SETOF TEXT
- AS $$ SELECT pg_ls_dir('pg_xlog') $$
- LANGUAGE SQL
- SECURITY DEFINER;
- REVOKE ALL ON FUNCTION ls_xlog_dir() FROM PUBLIC;
- GRANT EXECUTE ON FUNCTION ls_xlog_dir() to nagios;
- COMMIT;
+BEGIN;
+CREATE FUNCTION ls_xlog_dir()
+ RETURNS SETOF TEXT
+ AS $$ SELECT pg_ls_dir('pg_xlog') $$
+ LANGUAGE SQL
+ SECURITY DEFINER;
+REVOKE ALL ON FUNCTION ls_xlog_dir() FROM PUBLIC;
+GRANT EXECUTE ON FUNCTION ls_xlog_dir() to nagios;
+COMMIT;
Example 1: Check that the number of ready WAL files is 10 or less on host "pluto", using a wrapper function ls_xlog_dir
to avoid the need for superuser permissions
check_postgres_archive_ready --host=pluto --critical=10 --lsfunc=ls_xlog_dir
+check_postgres_archive_ready --host=pluto --critical=10 --lsfunc=ls_xlog_dir
For MRTG output, reports the number of WAL files on line 1.
@@ -1433,39 +1451,39 @@Only checks items named pg_class:
- --include=pg_class
+--include=pg_class
Only checks items containing the letters 'pg_':
- --include=~pg_
+--include=~pg_
Only check items beginning with 'pg_':
- --include=~^pg_
+--include=~^pg_
Exclude the item named 'test':
- --exclude=test
+--exclude=test
Exclude all items containing the letters 'test:
- --exclude=~test
+--exclude=~test
Exclude all items in the schema 'pg_catalog':
- --exclude='pg_catalog.'
+--exclude='pg_catalog.'
Exclude all items in the 'pg_temp_nnn' per-session temporary schemas:
- --exclude=~^pg_temp_.
+--exclude=~^pg_temp_.
Exclude all items containing the letters 'ace', but allow the item 'faceoff':
- --exclude=~ace --include=faceoff
+--exclude=~ace --include=faceoff
Exclude all items which start with the letters 'pg_', which contain the letters 'slon', or which are named 'sql_settings' or 'green'. Specifically check items with the letters 'prod' in their names, and always check the item named 'pg_relname':
- --exclude=~^pg_,~slon,sql_settings --exclude=green --include=~prod,pg_relname
+--exclude=~^pg_,~slon,sql_settings --exclude=green --include=~prod,pg_relname
Only check items owned by the user named greg:
- --includeuser=greg
+--includeuser=greg
Only check items owned by either watson or crick:
- --includeuser=watson,crick
+--includeuser=watson,crick
Only check items owned by crick,franklin, watson, or wilkins:
- --includeuser=watson --includeuser=franklin --includeuser=crick,wilkins
+--includeuser=watson --includeuser=franklin --includeuser=crick,wilkins
Check all items except for those belonging to the user scott:
- --excludeuser=scott
+--excludeuser=scott
Development happens using the git system. You can clone the latest version by doing:
- https://github.com/bucardo/check_postgres
- git clone git://bucardo.org/check_postgres.git
+https://github.com/bucardo/check_postgres
+git clone https://github.com/bucardo/check_postgres.git
Three mailing lists are available. For discussions about the program, bug reports, feature requests, and commit notices, send email to check_postgres@bucardo.org
-https://mail.endcrypt.com/mailman/listinfo/check_postgres
+https://bucardo.org/mailman/listinfo/check_postgres
A low-volume list for announcement of new versions and important notices is the 'check_postgres-announce' list:
-https://mail.endcrypt.com/mailman/listinfo/check_postgres-announce
- -Source code changes (via git-commit) are sent to the 'check_postgres-commit' list:
- -https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit
+https://bucardo.org/mailman/listinfo/check_postgres-announce
Add new action "pgbouncer_maxwait" (Ruslan Kabalin) [Github pull #59]
+Add new action "lockwait" showing details of blocked queries
+(Github user miraclesvenni)
+[Github issue #154]
+
+Raise minimum version or Perl to 5.10.0
+
+Allow commas in passwords via --dbpass for one-connection queries (Greg Sabino Mullane) [Github issue #133]
+
+Fix undefined variable error (Greg Sabino Mullane) [Github issue #141]
+
+
Add new action "pgbouncer_maxwait" (Ruslan Kabalin) [Github pull #59]
+
+For the bloat check, add option to populate all known databases,
+ as well as includsion and exclusion regexes. (Giles Westwood) [Github pull #86]
+
+Add Partman premake check (Jens Wilke) [Github pull #196]
+
+Add --role flag to explicitly set the role of the user after connecting (David Christensen)
- Fix check_replication_slots on recently promoted servers (Christoph Berg)
+Fix check_replication_slots on recently promoted servers (Christoph Berg)
- Allow the check_disk_space action to handle relative log_directory paths (jacksonfoz) [Github pull #174]
+Allow the check_disk_space action to handle relative log_directory paths (jacksonfoz) [Github pull #174]
- Fix MINPAGES and MINIPAGES in the "check_bloat" action (Christoph Moench-Tegeder) [Github pull #82]
+Fix MINPAGES and MINIPAGES in the "check_bloat" action (Christoph Moench-Tegeder) [Github pull #82]
- Replace 'which' with 'command -v' (Christoph Berg)
+Replace 'which' with 'command -v' (Christoph Berg)
- Fix check_replication_slots on recently promoted servers (Christoph Berg)
+Fix check_replication_slots on recently promoted servers (Christoph Berg)
- Add --role flag to explicitly set the role of the user after connecting (David Christensen)
+Fix undefined variable warning (Michael van Bracht) [Github pull #158]
- Add Partman premake check (Jens Wilke) [Github pull #196]
+In the tests, force log_destination to stderr (Christoph Moench-Tegeder) [Github pull #185]
- Add to docs how to exclude all items in the 'pg_temp_nnn' per-session temporary schemas (Michael Banck)
+Add to docs how to exclude all items in the 'pg_temp_nnn' per-session temporary schemas (Michael Banck)
- Various fixes for the CI system (Emre Hasegeli) [Github pull #181]
+Various fixes for the CI system (Emre Hasegeli) [Github pull #181]
- Various improvements to the tests (Christoph Berg, Emre Hasegeli)
+Various improvements to the tests (Christoph Berg, Emre Hasegeli)
Allow same_schema objects to be included or excluded with --object and --skipobject
- (Greg Sabino Mullane)
+Allow same_schema objects to be included or excluded with --object and --skipobject
+ (Greg Sabino Mullane)
- Fix to allow mixing service names and other connection parameters for same_schema
- (Greg Sabino Mullane)
+Fix to allow mixing service names and other connection parameters for same_schema
+ (Greg Sabino Mullane)
Support new_version_pg for PG10
- (Michael Pirogov)
+Support new_version_pg for PG10
+ (Michael Pirogov)
- Option to skip CYCLE sequences in action sequence
- (Christoph Moench-Tegeder)
+Option to skip CYCLE sequences in action sequence
+ (Christoph Moench-Tegeder)
- Output per-database perfdata for pgbouncer pool checks
- (George Hansper)
+Output per-database perfdata for pgbouncer pool checks
+ (George Hansper)
- German message translations
- (Holger Jacobs)
+German message translations
+ (Holger Jacobs)
- Consider only client backends in query_time and friends
- (David Christensen)
+Consider only client backends in query_time and friends
+ (David Christensen)
Support PostgreSQL 10.
- (David Christensen, Christoph Berg)
+Support PostgreSQL 10.
+ (David Christensen, Christoph Berg)
- Change table_size to use pg_table_size() on 9.0+, i.e. include the TOAST
- table size in the numbers reported. Add new actions indexes_size and
- total_relation_size, using the respective pg_indexes_size() and
- pg_total_relation_size() functions. All size checks will now also check
- materialized views where applicable.
- (Christoph Berg)
+Change table_size to use pg_table_size() on 9.0+, i.e. include the TOAST
+table size in the numbers reported. Add new actions indexes_size and
+total_relation_size, using the respective pg_indexes_size() and
+pg_total_relation_size() functions. All size checks will now also check
+materialized views where applicable.
+ (Christoph Berg)
- Connection errors are now always critical, not unknown.
- (Christoph Berg)
+Connection errors are now always critical, not unknown.
+ (Christoph Berg)
- New action replication_slots checking if logical or physical replication
- slots have accumulated too much data
- (Glyn Astill)
+New action replication_slots checking if logical or physical replication
+slots have accumulated too much data
+ (Glyn Astill)
- Multiple same_schema improvements
- (Glyn Astill)
+Multiple same_schema improvements
+ (Glyn Astill)
- Add Spanish message translations
- (Luis Vazquez)
+Add Spanish message translations
+ (Luis Vazquez)
- Allow a wrapper function to run wal_files and archive_ready actions as
- non-superuser
- (Joshua Elsasser)
+Allow a wrapper function to run wal_files and archive_ready actions as
+non-superuser
+ (Joshua Elsasser)
- Add some defensive casting to the bloat query
- (Greg Sabino Mullane)
+Add some defensive casting to the bloat query
+ (Greg Sabino Mullane)
- Invoke psql with option -X
- (Peter Eisentraut)
+Invoke psql with option -X
+ (Peter Eisentraut)
- Update postgresql.org URLs to use https.
- (Magnus Hagander)
+Update postgresql.org URLs to use https.
+ (Magnus Hagander)
- check_txn_idle: Don't fail when query contains 'disabled' word
- (Marco Nenciarini)
+check_txn_idle: Don't fail when query contains 'disabled' word
+ (Marco Nenciarini)
- check_txn_idle: Use state_change instead of query_start.
- (Sebastian Webber)
+check_txn_idle: Use state_change instead of query_start.
+ (Sebastian Webber)
- check_hot_standby_delay: Correct extra space in perfdata
- (Adrien Nayrat)
+check_hot_standby_delay: Correct extra space in perfdata
+ (Adrien Nayrat)
- Remove \r from psql output as it can confuse some regexes
- (Greg Sabino Mullane)
+Remove \r from psql output as it can confuse some regexes
+ (Greg Sabino Mullane)
- Sort failed jobs in check_pgagent_jobs for stable output.
- (Christoph Berg)
+Sort failed jobs in check_pgagent_jobs for stable output.
+ (Christoph Berg)
Add xact timestamp support to hot_standby_delay.
- Allow the hot_standby_delay check to accept xlog byte position or
- timestamp lag intervals as thresholds, or even both at the same time.
- (Josh Williams)
+Add xact timestamp support to hot_standby_delay.
+Allow the hot_standby_delay check to accept xlog byte position or
+timestamp lag intervals as thresholds, or even both at the same time.
+ (Josh Williams)
- Query all sequences per DB in parallel for action=sequence.
- (Christoph Berg)
+Query all sequences per DB in parallel for action=sequence.
+ (Christoph Berg)
- Fix bloat check to use correct SQL depending on the server version.
- (Adrian Vondendriesch)
+Fix bloat check to use correct SQL depending on the server version.
+ (Adrian Vondendriesch)
- Show actual long-running query in query_time output
- (Peter Eisentraut)
+Show actual long-running query in query_time output
+ (Peter Eisentraut)
- Add explicit ORDER BY to the slony_status check to get the most lagged server.
- (Jeff Frost)
+Add explicit ORDER BY to the slony_status check to get the most lagged server.
+ (Jeff Frost)
- Improved multi-slave support in replicate_row.
- (Andrew Yochum)
+Improved multi-slave support in replicate_row.
+ (Andrew Yochum)
- Change the way tables are quoted in replicate_row.
- (Glyn Astill)
+Change the way tables are quoted in replicate_row.
+ (Glyn Astill)
- Don't swallow space before the -c flag when reporting errors
- (Jeff Janes)
+Don't swallow space before the -c flag when reporting errors
+ (Jeff Janes)
- Fix and extend hot_standby_delay documentation
- (Michael Renner)
+Fix and extend hot_standby_delay documentation
+ (Michael Renner)
- Declare POD encoding to be utf8.
- (Christoph Berg)
+Declare POD encoding to be utf8.
+ (Christoph Berg)
Fix issue with SQL steps in check_pgagent_jobs for sql steps which perform deletes
- (Rob Emery via github pull)
+Fix issue with SQL steps in check_pgagent_jobs for sql steps which perform deletes
+ (Rob Emery via github pull)
- Install man page in section 1.
- (Peter Eisentraut, bug 53, github issue 26)
+Install man page in section 1.
+ (Peter Eisentraut, bug 53, github issue 26)
- Order lock types in check_locks output to make the ordering predictable;
- setting SKIP_NETWORK_TESTS will skip the new_version tests; other minor test
- suite fixes.
- (Christoph Berg)
+Order lock types in check_locks output to make the ordering predictable;
+setting SKIP_NETWORK_TESTS will skip the new_version tests; other minor test
+suite fixes.
+ (Christoph Berg)
- Fix same_schema check on 9.3 by ignoring relminmxid differences in pg_class
- (Christoph Berg)
+Fix same_schema check on 9.3 by ignoring relminmxid differences in pg_class
+ (Christoph Berg)
Make connection check failures return CRITICAL not UNKNOWN
- (Dominic Hargreaves)
+Make connection check failures return CRITICAL not UNKNOWN
+ (Dominic Hargreaves)
- Fix --reverse option when using string comparisons in custom queries
- (Nathaniel Waisbrot)
+Fix --reverse option when using string comparisons in custom queries
+ (Nathaniel Waisbrot)
- Compute correct 'totalwastedbytes' in the bloat query
- (Michael Renner)
+Compute correct 'totalwastedbytes' in the bloat query
+ (Michael Renner)
- Do not use pg_stats "inherited" column in bloat query, if the
- database is 8.4 or older. (Greg Sabino Mullane, per bug 121)
+Do not use pg_stats "inherited" column in bloat query, if the
+ database is 8.4 or older. (Greg Sabino Mullane, per bug 121)
- Remove host reordering in hot_standby_delay check
- (Josh Williams, with help from Jacobo Blasco)
+Remove host reordering in hot_standby_delay check
+ (Josh Williams, with help from Jacobo Blasco)
- Better output for the "simple" flag
- (Greg Sabino Mullane)
+Better output for the "simple" flag
+ (Greg Sabino Mullane)
- Force same_schema to ignore the 'relallvisible' column
- (Greg Sabino Mullane)
+Force same_schema to ignore the 'relallvisible' column
+ (Greg Sabino Mullane)
Add check for pgagent jobs (David E. Wheeler)
+Add check for pgagent jobs (David E. Wheeler)
- Force STDOUT to use utf8 for proper output
- (Greg Sabino Mullane; reported by Emmanuel Lesouef)
+Force STDOUT to use utf8 for proper output
+ (Greg Sabino Mullane; reported by Emmanuel Lesouef)
- Fixes for Postgres 9.2: new pg_stat_activity view,
- and use pg_tablespace_location, (Josh Williams)
+Fixes for Postgres 9.2: new pg_stat_activity view,
+ and use pg_tablespace_location, (Josh Williams)
- Allow for spaces in item lists when doing same_schema.
+Allow for spaces in item lists when doing same_schema.
- Allow txn_idle to work again for < 8.3 servers by switching to query_time.
+Allow txn_idle to work again for < 8.3 servers by switching to query_time.
- Fix the check_bloat SQL to take inherited tables into account,
- and assume 2k for non-analyzed columns. (Geert Pante)
+Fix the check_bloat SQL to take inherited tables into account,
+ and assume 2k for non-analyzed columns. (Geert Pante)
- Cache sequence information to speed up same_schema runs.
+Cache sequence information to speed up same_schema runs.
- Fix --excludeuser in check_txn_idle (Mika Eloranta)
+Fix --excludeuser in check_txn_idle (Mika Eloranta)
- Fix user clause handling in check_txn_idle (Michael van Bracht)
+Fix user clause handling in check_txn_idle (Michael van Bracht)
- Adjust docs to show colon as a better separator inside args for locks
- (Charles Sprickman)
+Adjust docs to show colon as a better separator inside args for locks
+ (Charles Sprickman)
- Fix undefined $SQL2 error in check_txn_idle [github issue 16] (Patric Bechtel)
+Fix undefined $SQL2 error in check_txn_idle [github issue 16] (Patric Bechtel)
- Prevent "uninitialized value" warnings when showing the port (Henrik Ahlgren)
+Prevent "uninitialized value" warnings when showing the port (Henrik Ahlgren)
- Do not assume everyone has a HOME [github issue 23]
+Do not assume everyone has a HOME [github issue 23]
Add the --assume-prod option (Cédric Villemain)
+Add the --assume-prod option (Cédric Villemain)
- Add the cluster_id check (Cédric Villemain)
+Add the cluster_id check (Cédric Villemain)
- Improve settings_checksum and checkpoint tests (Cédric Villemain)
+Improve settings_checksum and checkpoint tests (Cédric Villemain)
- Do not do an inner join to pg_user when checking database size
- (Greg Sabino Mullane; reported by Emmanuel Lesouef)
+Do not do an inner join to pg_user when checking database size
+ (Greg Sabino Mullane; reported by Emmanuel Lesouef)
- Use the full path when getting sequence information for same_schema.
- (Greg Sabino Mullane; reported by Cindy Wise)
+Use the full path when getting sequence information for same_schema.
+ (Greg Sabino Mullane; reported by Cindy Wise)
- Fix the formula for calculating xlog positions (Euler Taveira de Oliveira)
+Fix the formula for calculating xlog positions (Euler Taveira de Oliveira)
- Better ordering of output for bloat check - make indexes as important
- as tables (Greg Sabino Mullane; reported by Jens Wilke)
+Better ordering of output for bloat check - make indexes as important
+ as tables (Greg Sabino Mullane; reported by Jens Wilke)
- Show the dbservice if it was used at top of same_schema output
- (Mike Blackwell)
+Show the dbservice if it was used at top of same_schema output
+ (Mike Blackwell)
- Better installation paths (Greg Sabino Mullane, per bug 53)
+Better installation paths (Greg Sabino Mullane, per bug 53)
Redo the same_schema action. Use new --filter argument for all filtering.
- Allow comparisons between any number of databases.
- Remove the dbname2, dbport2, etc. arguments.
- Allow comparison of the same db over time.
+Redo the same_schema action. Use new --filter argument for all filtering.
+Allow comparisons between any number of databases.
+Remove the dbname2, dbport2, etc. arguments.
+Allow comparison of the same db over time.
- Swap db1 and db2 if the slave is 1 for the hot standby check (David E. Wheeler)
+Swap db1 and db2 if the slave is 1 for the hot standby check (David E. Wheeler)
- Allow multiple --schema arguments for the slony_status action (GSM and Jehan-Guillaume de Rorthais)
+Allow multiple --schema arguments for the slony_status action (GSM and Jehan-Guillaume de Rorthais)
- Fix ORDER BY in the last vacuum/analyze action (Nicolas Thauvin)
+Fix ORDER BY in the last vacuum/analyze action (Nicolas Thauvin)
- Fix check_hot_standby_delay perfdata output (Nicolas Thauvin)
+Fix check_hot_standby_delay perfdata output (Nicolas Thauvin)
- Look in the correct place for the .ready files with the archive_ready action (Nicolas Thauvin)
+Look in the correct place for the .ready files with the archive_ready action (Nicolas Thauvin)
- New action: commitratio (Guillaume Lelarge)
+New action: commitratio (Guillaume Lelarge)
- New action: hitratio (Guillaume Lelarge)
+New action: hitratio (Guillaume Lelarge)
- Make sure --action overrides the symlink naming trick.
+Make sure --action overrides the symlink naming trick.
- Set defaults for archive_ready and wal_files (Thomas Guettler, GSM)
+Set defaults for archive_ready and wal_files (Thomas Guettler, GSM)
- Better output for wal_files and archive_ready (GSM)
+Better output for wal_files and archive_ready (GSM)
- Fix warning when client_port set to empty string (bug #79)
+Fix warning when client_port set to empty string (bug #79)
- Account for "empty row" in -x output (i.e. source of functions).
+Account for "empty row" in -x output (i.e. source of functions).
- Fix some incorrectly named data fields (Andy Lester)
+Fix some incorrectly named data fields (Andy Lester)
- Expand the number of pgbouncer actions (Ruslan Kabalin)
+Expand the number of pgbouncer actions (Ruslan Kabalin)
- Give detailed information and refactor txn_idle, txn_time, and query_time
- (Per request from bug #61)
+Give detailed information and refactor txn_idle, txn_time, and query_time
+ (Per request from bug #61)
- Set maxalign to 8 in the bloat check if box identified as '64-bit'
- (Michel Sijmons, bug #66)
+Set maxalign to 8 in the bloat check if box identified as '64-bit'
+ (Michel Sijmons, bug #66)
- Support non-standard version strings in the bloat check.
- (Michel Sijmons and Gurjeet Singh, bug #66)
+Support non-standard version strings in the bloat check.
+ (Michel Sijmons and Gurjeet Singh, bug #66)
- Do not show excluded databases in some output (Ruslan Kabalin)
+Do not show excluded databases in some output (Ruslan Kabalin)
- Allow "and", "or" inside arguments (David E. Wheeler)
+Allow "and", "or" inside arguments (David E. Wheeler)
- Add the "new_version_box" action.
+Add the "new_version_box" action.
- Fix psql version regex (Peter Eisentraut, bug #69)
+Fix psql version regex (Peter Eisentraut, bug #69)
- Add the --assume-standby-mode option (Ruslan Kabalin)
+Add the --assume-standby-mode option (Ruslan Kabalin)
- Note that txn_idle and query_time require 8.3 (Thomas Guettler)
+Note that txn_idle and query_time require 8.3 (Thomas Guettler)
- Standardize and clean up all perfdata output (bug #52)
+Standardize and clean up all perfdata output (bug #52)
- Exclude "idle in transaction" from the query_time check (bug #43)
+Exclude "idle in transaction" from the query_time check (bug #43)
- Fix the perflimit for the bloat action (bug #50)
+Fix the perflimit for the bloat action (bug #50)
- Clean up the custom_query action a bit.
+Clean up the custom_query action a bit.
- Fix space in perfdata for hot_standby_delay action (Nicolas Thauvin)
+Fix space in perfdata for hot_standby_delay action (Nicolas Thauvin)
- Handle undef percents in check_fsm_relations (Andy Lester)
+Handle undef percents in check_fsm_relations (Andy Lester)
- Fix typo in dbstats action (Stas Vitkovsky)
+Fix typo in dbstats action (Stas Vitkovsky)
- Fix MRTG for last vacuum and last_analyze actions.
+Fix MRTG for last vacuum and last_analyze actions.
Add new action 'hot_standby_delay' (Nicolas Thauvin)
- Add cache-busting for the version-grabbing utilities.
- Fix problem with going to next method for new_version_pg
- (Greg Sabino Mullane, reported by Hywel Mallett in bug #65)
- Allow /usr/local/etc as an alternative location for the
- check_postgresrc file (Hywel Mallett)
- Do not use tgisconstraint in same_schema if Postgres >= 9
- (Guillaume Lelarge)
+Add new action 'hot_standby_delay' (Nicolas Thauvin)
+Add cache-busting for the version-grabbing utilities.
+Fix problem with going to next method for new_version_pg
+ (Greg Sabino Mullane, reported by Hywel Mallett in bug #65)
+Allow /usr/local/etc as an alternative location for the
+ check_postgresrc file (Hywel Mallett)
+Do not use tgisconstraint in same_schema if Postgres >= 9
+ (Guillaume Lelarge)
Fix warning when using symlinks
- (Greg Sabino Mullane, reported by Peter Eisentraut in bug #63)
+Fix warning when using symlinks
+ (Greg Sabino Mullane, reported by Peter Eisentraut in bug #63)
Show OK for no matching txn_idle entries.
+Show OK for no matching txn_idle entries.
Better formatting of sizes in the bloat action output.
+Better formatting of sizes in the bloat action output.
- Remove duplicate perfs in bloat action output.
+Remove duplicate perfs in bloat action output.
Fix problem when examining items in pg_settings (Greg Sabino Mullane)
+Fix problem when examining items in pg_settings (Greg Sabino Mullane)
- For connection test, return critical, not unknown, on FATAL errors
- (Greg Sabino Mullane, reported by Peter Eisentraut in bug #62)
+For connection test, return critical, not unknown, on FATAL errors
+ (Greg Sabino Mullane, reported by Peter Eisentraut in bug #62)
Add --quiet argument to suppress output on OK Nagios results
- Add index comparison for same_schema (Norman Yamada and Greg Sabino Mullane)
- Use $ENV{PGSERVICE} instead of "service=" to prevent problems (Guillaume Lelarge)
- Add --man option to show the entire manual. (Andy Lester)
- Redo the internal run_command() sub to use -x and hashes instead of regexes.
- Fix error in custom logic (Andreas Mager)
- Add the "pgbouncer_checksum" action (Guillaume Lelarge)
- Fix regex to work on WIN32 for check_fsm_relations and check_fsm_pages (Luke Koops)
- Don't apply a LIMIT when using --exclude on the bloat action (Marti Raudsepp)
- Change the output of query_time to show pid,user,port, and address (Giles Westwood)
- Fix to show database properly when using slony_status (Guillaume Lelarge)
- Allow warning items for same_schema to be comma-separated (Guillaume Lelarge)
- Constraint definitions across Postgres versions match better in same_schema.
- Work against "EnterpriseDB" databases (Sivakumar Krishnamurthy and Greg Sabino Mullane)
- Separate perfdata with spaces (Jehan-Guillaume (ioguix) de Rorthais)
- Add new action "archive_ready" (Jehan-Guillaume (ioguix) de Rorthais)
+Add --quiet argument to suppress output on OK Nagios results
+Add index comparison for same_schema (Norman Yamada and Greg Sabino Mullane)
+Use $ENV{PGSERVICE} instead of "service=" to prevent problems (Guillaume Lelarge)
+Add --man option to show the entire manual. (Andy Lester)
+Redo the internal run_command() sub to use -x and hashes instead of regexes.
+Fix error in custom logic (Andreas Mager)
+Add the "pgbouncer_checksum" action (Guillaume Lelarge)
+Fix regex to work on WIN32 for check_fsm_relations and check_fsm_pages (Luke Koops)
+Don't apply a LIMIT when using --exclude on the bloat action (Marti Raudsepp)
+Change the output of query_time to show pid,user,port, and address (Giles Westwood)
+Fix to show database properly when using slony_status (Guillaume Lelarge)
+Allow warning items for same_schema to be comma-separated (Guillaume Lelarge)
+Constraint definitions across Postgres versions match better in same_schema.
+Work against "EnterpriseDB" databases (Sivakumar Krishnamurthy and Greg Sabino Mullane)
+Separate perfdata with spaces (Jehan-Guillaume (ioguix) de Rorthais)
+Add new action "archive_ready" (Jehan-Guillaume (ioguix) de Rorthais)
Allow slony_status action to handle more than one slave.
- Use commas to separate function args in same_schema output (Robert Treat)
+Allow slony_status action to handle more than one slave.
+Use commas to separate function args in same_schema output (Robert Treat)
Change autovac_freeze default warn/critical back to 90%/95% (Robert Treat)
- Put all items one-per-line for relation size actions if --verbose=1
+Change autovac_freeze default warn/critical back to 90%/95% (Robert Treat)
+Put all items one-per-line for relation size actions if --verbose=1
Don't use $^T in logfile check, as script may be long-running
- Change the error string for the logfile action for easier exclusion
- by programs like tail_n_mail
+Don't use $^T in logfile check, as script may be long-running
+Change the error string for the logfile action for easier exclusion
+ by programs like tail_n_mail
Added the 'slony_status' action.
- Changed the logfile sleep from 0.5 to 1, as 0.5 gets rounded to 0 on some boxes!
+Added the 'slony_status' action.
+Changed the logfile sleep from 0.5 to 1, as 0.5 gets rounded to 0 on some boxes!
Allow timeout option to be used for logtime 'sleep' time.
+Allow timeout option to be used for logtime 'sleep' time.
Show offending database for query_time action.
- Apply perflimit to main output for sequence action.
- Add 'noowner' option to same_schema action.
- Raise sleep timeout for logfile check to 15 seconds.
+Show offending database for query_time action.
+Apply perflimit to main output for sequence action.
+Add 'noowner' option to same_schema action.
+Raise sleep timeout for logfile check to 15 seconds.
Fix bug preventing column constraint differences from 2 > 1 for same_schema from being shown.
- Allow aliases 'dbname1', 'dbhost1', 'dbport1',etc.
- Added "nolanguage" as a filter for the same_schema option.
- Don't track "generic" table constraints (e.. $1, $2) using same_schema
+Fix bug preventing column constraint differences from 2 > 1 for same_schema from being shown.
+Allow aliases 'dbname1', 'dbhost1', 'dbport1',etc.
+Added "nolanguage" as a filter for the same_schema option.
+Don't track "generic" table constraints (e.. $1, $2) using same_schema
Allow "nofunctions" as a filter for the same_schema option.
- Added "noperm" as a filter for the same_schema option.
- Ignore dropped columns when considered positions for same_schema (Guillaume Lelarge)
+Allow "nofunctions" as a filter for the same_schema option.
+Added "noperm" as a filter for the same_schema option.
+Ignore dropped columns when considered positions for same_schema (Guillaume Lelarge)
Change autovac_freeze default warn/critical from 90%/95% to 105%/120% (Marti Raudsepp)
+Change autovac_freeze default warn/critical from 90%/95% to 105%/120% (Marti Raudsepp)
Allow the temporary directory to be specified via the "tempdir" argument,
- for systems that need it (e.g. /tmp is not owned by root).
- Fix so old versions of Postgres (< 8.0) use the correct default database (Giles Westwood)
- For "same_schema" trigger mismatches, show the attached table.
- Add the new_version_bc check for Bucardo version checking.
- Add database name to perf output for last_vacuum|analyze (Guillaume Lelarge)
- Fix for bloat action against old versions of Postgres without the 'block_size' param.
+Allow the temporary directory to be specified via the "tempdir" argument,
+ for systems that need it (e.g. /tmp is not owned by root).
+Fix so old versions of Postgres (< 8.0) use the correct default database (Giles Westwood)
+For "same_schema" trigger mismatches, show the attached table.
+Add the new_version_bc check for Bucardo version checking.
+Add database name to perf output for last_vacuum|analyze (Guillaume Lelarge)
+Fix for bloat action against old versions of Postgres without the 'block_size' param.
Proper Nagios output for last_vacuum|analyze actions. (Cédric Villemain)
- Proper Nagios output for locks action. (Cédric Villemain)
- Proper Nagios output for txn_wraparound action. (Cédric Villemain)
- Fix for constraints with embedded newlines for same_schema.
- Allow --exclude for all items when using same_schema.
+Proper Nagios output for last_vacuum|analyze actions. (Cédric Villemain)
+Proper Nagios output for locks action. (Cédric Villemain)
+Proper Nagios output for txn_wraparound action. (Cédric Villemain)
+Fix for constraints with embedded newlines for same_schema.
+Allow --exclude for all items when using same_schema.
Add Nagios perf output to the wal_files check (Cédric Villemain)
- Add support for .check_postgresrc, per request from Albe Laurenz.
- Allow list of web fetch methods to be changed with the --get_method option.
- Add support for the --language argument, which overrides any ENV.
- Add the --no-check_postgresrc flag.
- Ensure check_postgresrc options are completely overridden by command-line options.
- Fix incorrect warning > critical logic in replicate_rows (Glyn Astill)
+Add Nagios perf output to the wal_files check (Cédric Villemain)
+Add support for .check_postgresrc, per request from Albe Laurenz.
+Allow list of web fetch methods to be changed with the --get_method option.
+Add support for the --language argument, which overrides any ENV.
+Add the --no-check_postgresrc flag.
+Ensure check_postgresrc options are completely overridden by command-line options.
+Fix incorrect warning > critical logic in replicate_rows (Glyn Astill)
For same_schema, compare view definitions, and compare languages.
- Make script into a global executable via the Makefile.PL file.
- Better output when comparing two databases.
- Proper Nagios output syntax for autovac_freeze and backends checks (Cédric Villemain)
+For same_schema, compare view definitions, and compare languages.
+Make script into a global executable via the Makefile.PL file.
+Better output when comparing two databases.
+Proper Nagios output syntax for autovac_freeze and backends checks (Cédric Villemain)
Don't use a LIMIT in check_bloat if --include is used. Per complaint from Jeff Frost.
+Don't use a LIMIT in check_bloat if --include is used. Per complaint from Jeff Frost.
More French translations (Guillaume Lelarge)
+More French translations (Guillaume Lelarge)
Quote dbname in perf output for the backends check. (Davide Abrigo)
- Add 'fetch' as an alternative method for new_version checks, as this
- comes by default with FreeBSD. (Hywel Mallett)
+Quote dbname in perf output for the backends check. (Davide Abrigo)
+Add 'fetch' as an alternative method for new_version checks, as this
+ comes by default with FreeBSD. (Hywel Mallett)
Allow dots and dashes in database name for the backends check (Davide Abrigo)
- Check and display the database for each match in the bloat check (Cédric Villemain)
- Handle 'too many connections' FATAL error in the backends check with a critical,
- rather than a generic error (Greg, idea by Jürgen Schulz-Brüssel)
- Do not allow perflimit to interfere with exclusion rules in the vacuum and
- analyze tests. (Greg, bug reported by Jeff Frost)
+Allow dots and dashes in database name for the backends check (Davide Abrigo)
+Check and display the database for each match in the bloat check (Cédric Villemain)
+Handle 'too many connections' FATAL error in the backends check with a critical,
+ rather than a generic error (Greg, idea by Jürgen Schulz-Brüssel)
+Do not allow perflimit to interfere with exclusion rules in the vacuum and
+ analyze tests. (Greg, bug reported by Jeff Frost)
Fix for multiple databases with the check_bloat action (Mark Kirkwood)
- Fixes and improvements to the same_schema action (Jeff Boes)
- Write tests for same_schema, other minor test fixes (Jeff Boes)
+Fix for multiple databases with the check_bloat action (Mark Kirkwood)
+Fixes and improvements to the same_schema action (Jeff Boes)
+Write tests for same_schema, other minor test fixes (Jeff Boes)
Added the same_schema action (Greg)
+Added the same_schema action (Greg)
Added timeout via statement_timeout in addition to perl alarm (Greg)
+Added timeout via statement_timeout in addition to perl alarm (Greg)
Added internationalization support (Greg)
- Added the 'disabled_triggers' check (Greg)
- Added the 'prepared_txns' check (Greg)
- Added the 'new_version_cp' and 'new_version_pg' checks (Greg)
- French translations (Guillaume Lelarge)
- Make the backends search return ok if no matches due to inclusion rules,
- per report by Guillaume Lelarge (Greg)
- Added comprehensive unit tests (Greg, Jeff Boes, Selena Deckelmann)
- Make fsm_pages and fsm_relations handle 8.4 servers smoothly. (Greg)
- Fix missing 'upd' field in show_dbstats (Andras Fabian)
- Allow ENV{PGCONTROLDATA} and ENV{PGBINDIR}. (Greg)
- Add various Perl module infrastructure (e.g. Makefile.PL) (Greg)
- Fix incorrect regex in txn_wraparound (Greg)
- For txn_wraparound: consistent ordering and fix duplicates in perf output (Andras Fabian)
- Add in missing exabyte regex check (Selena Deckelmann)
- Set stats to zero if we bail early due to USERWHERECLAUSE (Andras Fabian)
- Add additional items to dbstats output (Andras Fabian)
- Remove --schema option from the fsm_ checks. (Greg Mullane and Robert Treat)
- Handle case when ENV{PGUSER} is set. (Andy Lester)
- Many various fixes. (Jeff Boes)
- Fix --dbservice: check version and use ENV{PGSERVICE} for old versions (Cédric Villemain)
+Added internationalization support (Greg)
+Added the 'disabled_triggers' check (Greg)
+Added the 'prepared_txns' check (Greg)
+Added the 'new_version_cp' and 'new_version_pg' checks (Greg)
+French translations (Guillaume Lelarge)
+Make the backends search return ok if no matches due to inclusion rules,
+ per report by Guillaume Lelarge (Greg)
+Added comprehensive unit tests (Greg, Jeff Boes, Selena Deckelmann)
+Make fsm_pages and fsm_relations handle 8.4 servers smoothly. (Greg)
+Fix missing 'upd' field in show_dbstats (Andras Fabian)
+Allow ENV{PGCONTROLDATA} and ENV{PGBINDIR}. (Greg)
+Add various Perl module infrastructure (e.g. Makefile.PL) (Greg)
+Fix incorrect regex in txn_wraparound (Greg)
+For txn_wraparound: consistent ordering and fix duplicates in perf output (Andras Fabian)
+Add in missing exabyte regex check (Selena Deckelmann)
+Set stats to zero if we bail early due to USERWHERECLAUSE (Andras Fabian)
+Add additional items to dbstats output (Andras Fabian)
+Remove --schema option from the fsm_ checks. (Greg Mullane and Robert Treat)
+Handle case when ENV{PGUSER} is set. (Andy Lester)
+Many various fixes. (Jeff Boes)
+Fix --dbservice: check version and use ENV{PGSERVICE} for old versions (Cédric Villemain)
Make the sequence action check if sequence being used for a int4 column and
- react appropriately. (Michael Glaesemann)
+Make the sequence action check if sequence being used for a int4 column and
+react appropriately. (Michael Glaesemann)
Fix to prevent multiple groupings if db arguments given.
+Fix to prevent multiple groupings if db arguments given.
Allow the -p argument for port to work again.
+Allow the -p argument for port to work again.
Do not require a connection argument, but use defaults and ENV variables when
- possible: PGHOST, PGPORT, PGUSER, PGDATABASE.
+Do not require a connection argument, but use defaults and ENV variables when
+ possible: PGHOST, PGPORT, PGUSER, PGDATABASE.
Only require Date::Parse to be loaded if using the checkpoint action.
+Only require Date::Parse to be loaded if using the checkpoint action.
Add the 'checkpoint' action.
+Add the 'checkpoint' action.
Better checking of $opt{dbservice} structure (Cédric Villemain)
- Fix time display in timesync action output (Selena Deckelmann)
- Fix documentation typos (Josh Tolley)
+Better checking of $opt{dbservice} structure (Cédric Villemain)
+Fix time display in timesync action output (Selena Deckelmann)
+Fix documentation typos (Josh Tolley)
Minor fix to regex in verify_version (Lee Jensen)
+Minor fix to regex in verify_version (Lee Jensen)
Minor documentation tweak.
+Minor documentation tweak.
Add support for --noidle flag to prevent backends action from counting idle processes.
- Patch by Selena Deckelmann.
+Add support for --noidle flag to prevent backends action from counting idle processes.
+Patch by Selena Deckelmann.
- Fix small undefined warning when not using --dbservice.
+Fix small undefined warning when not using --dbservice.
Add support for the pg_Service.conf file with the --dbservice option.
+Add support for the pg_Service.conf file with the --dbservice option.
Fix options for replicate_row action, per report from Jason Gordon.
+Fix options for replicate_row action, per report from Jason Gordon.
Wrap File::Temp::cleanup() calls in eval, in case File::Temp is an older version.
- Patch by Chris Butler.
+Wrap File::Temp::cleanup() calls in eval, in case File::Temp is an older version.
+Patch by Chris Butler.
Cast numbers to numeric to support sequences ranges > bigint in check_sequence action.
- Thanks to Scott Marlowe for reporting this.
+Cast numbers to numeric to support sequences ranges > bigint in check_sequence action.
+Thanks to Scott Marlowe for reporting this.
Add Cacti support with the dbstats action.
- Pretty up the time output for last vacuum and analyze actions.
- Show the percentage of backends on the check_backends action.
+Add Cacti support with the dbstats action.
+Pretty up the time output for last vacuum and analyze actions.
+Show the percentage of backends on the check_backends action.
Fix minor warning in action check_bloat with multiple databases.
- Allow warning to be greater than critical when using the --reverse option.
- Support the --perflimit option for the check_sequence action.
+Fix minor warning in action check_bloat with multiple databases.
+Allow warning to be greater than critical when using the --reverse option.
+Support the --perflimit option for the check_sequence action.
Minor tweak to way we store the default port.
+Minor tweak to way we store the default port.
Allow the default port to be changed easily.
- Allow transform of simple output by MB, GB, etc.
+Allow the default port to be changed easily.
+Allow transform of simple output by MB, GB, etc.
Allow multiple databases in 'sequence' action. Reported by Christoph Zwerschke.
+Allow multiple databases in 'sequence' action. Reported by Christoph Zwerschke.
Add missing $schema to check_fsm_pages. (Robert Treat)
+Add missing $schema to check_fsm_pages. (Robert Treat)
Change option 'checktype' to 'valtype' to prevent collisions with -c[ritical]
- Better handling of errors.
+Change option 'checktype' to 'valtype' to prevent collisions with -c[ritical]
+Better handling of errors.
Do explicit cleanups of the temp directory, per problems reported by sb@nnx.com.
+Do explicit cleanups of the temp directory, per problems reported by sb@nnx.com.
Account for cases where some rounding queries give -0 instead of 0.
- Thanks to Glyn Astill for helping to track this down.
+Account for cases where some rounding queries give -0 instead of 0.
+Thanks to Glyn Astill for helping to track this down.
Always quote identifiers in check_replicate_row action.
+Always quote identifiers in check_replicate_row action.
Give a better error if one of the databases cannot be reached.
+Give a better error if one of the databases cannot be reached.
Add the "sequence" action, thanks to Gavin M. Roy for the idea.
- Fix minor problem with autovac_freeze action when using MRTG output.
- Allow output argument to be case-insensitive.
- Documentation fixes.
+Add the "sequence" action, thanks to Gavin M. Roy for the idea.
+Fix minor problem with autovac_freeze action when using MRTG output.
+Allow output argument to be case-insensitive.
+Documentation fixes.
Fix some minor typos
+Fix some minor typos
Expand range of allowed names for --repinfo argument (Glyn Astill)
- Documentation tweaks.
+Expand range of allowed names for --repinfo argument (Glyn Astill)
+Documentation tweaks.
Fixes for minor output and scoping problems.
+Fixes for minor output and scoping problems.
Add MRTG output to fsm_pages and fsm_relations.
- Force error messages to one-line for proper Nagios output.
- Check for invalid prereqs on failed command. From conversations with Euler Taveira de Oliveira.
- Tweak the fsm_pages formula a little.
+Add MRTG output to fsm_pages and fsm_relations.
+Force error messages to one-line for proper Nagios output.
+Check for invalid prereqs on failed command. From conversations with Euler Taveira de Oliveira.
+Tweak the fsm_pages formula a little.
Add fsm_pages and fsm_relations actions. (Robert Treat)
+Add fsm_pages and fsm_relations actions. (Robert Treat)
Fix for race condition in txn_time action.
- Add --debugoutput option.
+Fix for race condition in txn_time action.
+Add --debugoutput option.
Allow alternate arguments "dbhost" for "host" and "dbport" for "port".
- Output a zero as default value for second line of MRTG output.
+Allow alternate arguments "dbhost" for "host" and "dbport" for "port".
+Output a zero as default value for second line of MRTG output.
Fix sorting error in the "disk_space" action for non-Nagios output.
- Allow --simple as a shortcut for --output=simple.
+Fix sorting error in the "disk_space" action for non-Nagios output.
+Allow --simple as a shortcut for --output=simple.
Don't check databases with datallowconn false for the "autovac_freeze" action.
+Don't check databases with datallowconn false for the "autovac_freeze" action.
Add the "autovac_freeze" action, thanks to Robert Treat for the idea and design.
- Put an ORDER BY on the "txn_wraparound" action.
+Add the "autovac_freeze" action, thanks to Robert Treat for the idea and design.
+Put an ORDER BY on the "txn_wraparound" action.
Optimizations to speed up the "bloat" action quite a bit.
- Fix "version" action to not always output in mrtg mode.
+Optimizations to speed up the "bloat" action quite a bit.
+Fix "version" action to not always output in mrtg mode.
Add support for MRTG and "simple" output options.
- Many small improvements to nearly all actions.
+Add support for MRTG and "simple" output options.
+Many small improvements to nearly all actions.
Fix an error in the bloat SQL in 1.9.0
- Allow percentage arguments to be over 99%
- Allow percentages in the bloat --warning and --critical (thanks to Robert Treat for the idea)
+Fix an error in the bloat SQL in 1.9.0
+Allow percentage arguments to be over 99%
+Allow percentages in the bloat --warning and --critical (thanks to Robert Treat for the idea)
Don't include information_schema in certain checks. (Jeff Frost)
- Allow --include and --exclude to use schemas by using a trailing period.
+Don't include information_schema in certain checks. (Jeff Frost)
+Allow --include and --exclude to use schemas by using a trailing period.
Output schema name before table name where appropriate.
- Thanks to Jeff Frost.
+Output schema name before table name where appropriate.
+Thanks to Jeff Frost.
Better detection of problems in --replicate_row.
+Better detection of problems in --replicate_row.
Fix 'backends' action: there may be no rows in pg_stat_activity, so run a second
- query if needed to find the max_connections setting.
- Thanks to Jeff Frost for the bug report.
+Fix 'backends' action: there may be no rows in pg_stat_activity, so run a second
+ query if needed to find the max_connections setting.
+Thanks to Jeff Frost for the bug report.
Changes to allow working under Nagios' embedded Perl mode. (Ioannis Tambouras)
+Changes to allow working under Nagios' embedded Perl mode. (Ioannis Tambouras)
Allow 'bloat' action to work on Postgres version 8.0.
- Allow for different commands to be run for each action depending on the server version.
- Give better warnings when running actions not available on older Postgres servers.
+Allow 'bloat' action to work on Postgres version 8.0.
+Allow for different commands to be run for each action depending on the server version.
+Give better warnings when running actions not available on older Postgres servers.
Add the --reverse option to the custom_query action.
+Add the --reverse option to the custom_query action.
Fix 'query_time' action: account for race condition in which zero rows appear in pg_stat_activity.
- Thanks to Dustin Black for the bug report.
+Fix 'query_time' action: account for race condition in which zero rows appear in pg_stat_activity.
+Thanks to Dustin Black for the bug report.
Add --replicate_row action
+Add --replicate_row action
Add --symlinks option as a shortcut to --action=rebuild_symlinks
+Add --symlinks option as a shortcut to --action=rebuild_symlinks
Add the custom_query action.
+Add the custom_query action.
Fix problem with too eager creation of custom pgpass file.
+Fix problem with too eager creation of custom pgpass file.
Add example Nagios configuration settings (Brian A. Seklecki)
+Add example Nagios configuration settings (Brian A. Seklecki)
Add the --includeuser and --excludeuser options. Documentation cleanup.
+Add the --includeuser and --excludeuser options. Documentation cleanup.
Add in the 'output' concept for future support of non-Nagios programs.
+Add in the 'output' concept for future support of non-Nagios programs.
Fix bug preventing --dbpass argument from working (Robert Treat).
+Fix bug preventing --dbpass argument from working (Robert Treat).
Minor documentation fixes.
+Minor documentation fixes.
Have 'wal_files' action use pg_ls_dir (idea by Robert Treat).
- For last_vacuum and last_analyze, respect autovacuum effects, add separate
- autovacuum checks (ideas by Robert Treat).
+Have 'wal_files' action use pg_ls_dir (idea by Robert Treat).
+For last_vacuum and last_analyze, respect autovacuum effects, add separate
+ autovacuum checks (ideas by Robert Treat).
Have txn_idle use query_start, not xact_start.
+Have txn_idle use query_start, not xact_start.
Add in txn_idle and txn_time actions.
+Add in txn_idle and txn_time actions.
Add the 'wal_files' action, which counts the number of WAL files
- in your pg_xlog directory.
- Fix some typos in the docs.
- Explicitly allow -v as an argument.
- Allow for a null syslog_facility in the 'logfile' action.
+Add the 'wal_files' action, which counts the number of WAL files
+ in your pg_xlog directory.
+Fix some typos in the docs.
+Explicitly allow -v as an argument.
+Allow for a null syslog_facility in the 'logfile' action.
Fix error preventing --action=rebuild_symlinks from working.
+Fix error preventing --action=rebuild_symlinks from working.
Switch vacuum and analyze date output to use 'DD', not 'D'. (Glyn Astill)
+Switch vacuum and analyze date output to use 'DD', not 'D'. (Glyn Astill)
Fixes, enhancements, and performance tracking.
- Add performance data tracking via --showperf and --perflimit
- Lots of refactoring and cleanup of how actions handle arguments.
- Do basic checks to figure out syslog file for 'logfile' action.
- Allow for exact matching of beta versions with 'version' action.
- Redo the default arguments to only populate when neither 'warning' nor 'critical' is provided.
- Allow just warning OR critical to be given for the 'timesync' action.
- Remove 'redirect_stderr' requirement from 'logfile' due to 8.3 changes.
- Actions 'last_vacuum' and 'last_analyze' are 8.2 only (Robert Treat)
+Fixes, enhancements, and performance tracking.
+Add performance data tracking via --showperf and --perflimit
+Lots of refactoring and cleanup of how actions handle arguments.
+Do basic checks to figure out syslog file for 'logfile' action.
+Allow for exact matching of beta versions with 'version' action.
+Redo the default arguments to only populate when neither 'warning' nor 'critical' is provided.
+Allow just warning OR critical to be given for the 'timesync' action.
+Remove 'redirect_stderr' requirement from 'logfile' due to 8.3 changes.
+Actions 'last_vacuum' and 'last_analyze' are 8.2 only (Robert Treat)
First public release, December 2007
+First public release, December 2007
Some example Nagios configuration settings using this script:
- define command {
- command_name check_postgres_size
- command_line $USER2$/check_postgres.pl -H $HOSTADDRESS$ -u pgsql -db postgres --action database_size -w $ARG1$ -c $ARG2$
- }
+define command {
+ command_name check_postgres_size
+ command_line $USER2$/check_postgres.pl -H $HOSTADDRESS$ -u pgsql -db postgres --action database_size -w $ARG1$ -c $ARG2$
+}
- define command {
- command_name check_postgres_locks
- command_line $USER2$/check_postgres.pl -H $HOSTADDRESS$ -u pgsql -db postgres --action locks -w $ARG1$ -c $ARG2$
- }
+define command {
+ command_name check_postgres_locks
+ command_line $USER2$/check_postgres.pl -H $HOSTADDRESS$ -u pgsql -db postgres --action locks -w $ARG1$ -c $ARG2$
+}
- define service {
- use generic-other
- host_name dbhost.gtld
- service_description dbhost PostgreSQL Service Database Usage Size
- check_command check_postgres_size!256000000!512000000
- }
+define service {
+ use generic-other
+ host_name dbhost.gtld
+ service_description dbhost PostgreSQL Service Database Usage Size
+ check_command check_postgres_size!256000000!512000000
+}
- define service {
- use generic-other
- host_name dbhost.gtld
- service_description dbhost PostgreSQL Service Database Locks
- check_command check_postgres_locks!2!3
- }
+define service {
+ use generic-other
+ host_name dbhost.gtld
+ service_description dbhost PostgreSQL Service Database Locks
+ check_command check_postgres_locks!2!3
+}
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
From ba25b10a040839e80f061041e0a5aa5ece8a6ff0 Mon Sep 17 00:00:00 2001 From: Greg Sabino MullaneCopyright 2007 - 2023 Greg Sabino Mullane <greg@turnstep.com>.
+Copyright 2007 - 2024 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
From 8a23adc3e19ccb6fd6b38629192e82eb3cb34a3b Mon Sep 17 00:00:00 2001 From: Greg Sabino MullaneCopyright 2007 - 2024 Greg Sabino Mullane <greg@turnstep.com>.
+Copyright 2007 - 2025 Greg Sabino Mullane <greg@turnstep.com>.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: