## Check the current database mode
our $STANDBY = 0;
-check_standby_mode() if $opt{'assume-standby-mode'};
+make_sure_standby_mode() if $opt{'assume-standby-mode'};
## We don't (usually) want to die, but want a graceful Nagios-like exit instead
sub ndie {
do_mrtg({one => $one, two => $two, msg => $msg});
}
-sub check_standby_mode {
+sub make_sure_standby_mode {
## Checks if database in standby mode
## Requires $ENV{PGDATA} or --datadir
return;
-} ## end of check_standby_mode
+} ## end of make_sure_standby_mode
sub finishup {
sub setup_target_databases {
## Build a list of all databases to connect to.
- ## Returns a list of all such databases with conenction information:
+ ## Returns a list of all such databases with connection information:
## -- dbuser, --dbpass, --dbservice, --port, --dbname, --host
##
## Items are determined by host, port, and db arguments
## --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
- ## Returns a list of targets as as hashref
+ ## Returns a list of targets as a hashref
my $arg = shift || {};
ndie msg('rep-wrongvals', $value1, $val1, $val2);
}
- $info1 = run_command($update, { failok => 1 } );
+ $info1 = run_command($update, { dbnumber => 1, failok => 1 } );
## Make sure the update worked
if (! defined $info1->{db}[0]) {
See: http://bucardo.org/wiki/Tail_n_mail for more information).
See also the information on the C<--get_method> option.
-=head2 B<pgbouncer_checksum>
-
-(C<symlink: check_postgres_pgbouncer_checksum>) Checks that all the
-pgBouncer settings are the same as last time you checked.
-This is done by generating a checksum of a sorted list of setting names and
-their values. Note that you shouldn't specify the database name, it will
-automatically default to pgbouncer. Either the I<--warning> or the I<--critical> option
-should be given, but not both. The value of each one is the checksum, a
-32-character hexadecimal value. You can run with the special C<--critical=0> option
-to find out an existing checksum.
-
-This action requires the Digest::MD5 module.
-
-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
-
-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
-
-For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A
-checksum must be provided as the C<--mrtg> argument. The fourth line always gives the
-current checksum.
-
=head2 B<pgb_pool_cl_active>
=head2 B<pgb_pool_cl_waiting>
max_client_conn. If more than one database has been queried, the one with the
highest number of connections is output.
+=head2 B<pgbouncer_checksum>
+
+(C<symlink: check_postgres_pgbouncer_checksum>) Checks that all the
+pgBouncer settings are the same as last time you checked.
+This is done by generating a checksum of a sorted list of setting names and
+their values. Note that you shouldn't specify the database name, it will
+automatically default to pgbouncer. Either the I<--warning> or the I<--critical> option
+should be given, but not both. The value of each one is the checksum, a
+32-character hexadecimal value. You can run with the special C<--critical=0> option
+to find out an existing checksum.
+
+This action requires the Digest::MD5 module.
+
+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
+
+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
+
+For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A
+checksum must be provided as the C<--mrtg> argument. The fourth line always gives the
+current checksum.
+
=head2 B<prepared_txns>
(C<symlink: check_postgres_prepared_txns>) Check on the age of any existing prepared transactions.
like ($cp->run('-c 40%'), qr{^$label OK}, $t);
$t=qq{$S works with critical option as a negative number};
-like ($cp->run('-c -6'), qr{^$label CRITICAL}, $t);
-like ($cp->run('-c -7'), qr{^$label CRITICAL}, $t);
-$num = $goodver ? 8 : 9;
-like ($cp->run("-c -$num"), qr{^$label OK}, $t);
+like ($cp->run('-c -5'), qr{^$label OK}, $t);
+like ($cp->run('-c -6'), qr{^$label OK}, $t);
+$num = $goodver ? 7 : 8;
+like ($cp->run("-c -$num"), qr{^$label CRITICAL}, $t);
$t=qq{$S works when no items caught by pg_stat_activity};
like ($cp->run('--include=postgres --exclude=postgres'), qr{^$label OK: .+3 of 10}, $t);
$t=qq{$S returned correct performance data with include};
- like ($cp->run('--include=postgres'), qr{ \| time=\d\.\d\ds ardala=0;9;9;0;10 beedeebeedee=0;9;9;0;10 postgres=3;9;9;0;10}, $t);
+ like ($cp->run('--include=postgres'), qr{ \| time=\d\.\d\ds postgres=3;9;9;0;10}, $t);
}
my %dbh;
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--critical=50'), qr{ERROR:.+must be a percentage}, $t);
+my $ver = $dbh->{pg_server_version};
+if ($ver >= 80400) {
+ SKIP: {
+ skip 'Cannot test fsm_pages completely on Postgres 8.4 or higher', 3;
+ }
+
+ $t=qq{$S gives an unknown when running against a 8.4 or higher version};
+ like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_pages}, $t);
+
+ exit;
+
+}
+
## Create a fake fsm 'view' for testing
$cp->set_fake_schema();
my $schema = $cp->get_fake_schema();
});
$dbh->commit();
-my $ver = $dbh->{pg_server_version};
-if ($ver >= 80400) {
- SKIP: {
- skip 'Cannot test fsm_pages completely on Postgres 8.4 or higher', 3;
- }
-
- $t=qq{$S gives an unknown when running against a 8.4 or higher version};
- like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_pages}, $t);
-
- exit;
-
-}
-
$t=qq{$S gives normal output for empty tables};
like ($cp->run('--warning=10%'), qr{^$label OK: .+fsm page slots used: 0 of \d+}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--critical=50'), qr{ERROR:.+must be a percentage}, $t);
+my $ver = $dbh->{pg_server_version};
+if ($ver >= 80400) {
+ SKIP: {
+ skip 'Cannot test fsm_relations completely on Postgres 8.4 or higher', 3;
+ }
+
+ $t=qq{$S gives an unknown when running against a 8.4 or higher version};
+ like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_relations}, $t);
+
+ exit;
+}
+
## Create a fake fsm 'view' for testing
$cp->set_fake_schema();
my $schema = $cp->get_fake_schema();
});
$dbh->commit();
-my $ver = $dbh->{pg_server_version};
-if ($ver >= 80400) {
- SKIP: {
- skip 'Cannot test fsm_relations completely on Postgres 8.4 or higher', 3;
- }
-
- $t=qq{$S gives an unknown when running against a 8.4 or higher version};
- like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_relations}, $t);
-
- exit;
-}
-
$t=qq{$S gives normal output for empty tables};
like ($cp->run('--warning=10%'), qr{^$label OK: .+fsm relations used: 0 of \d+}, $t);