=head2 B<hot_standby_delay>
(C<symlink: check_hot_standby_delay>) Checks the streaming replication lag by computing the delta
- between the xlog position of a master server and the one of the slaves connected to it, and/or the
- last transaction timestamp received by the slave. 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. To support transaction
- timestamps the minimum version is Postgres 9.1.
-
- The I<--warning> and I<--critical> options are either the delta between xlog positions in bytes,
- units of time to compare timestamps, or both.
+ between the current xlog position of a master server and the replay location of a slave connected
+ 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.
+
+ The first "--dbname", "--host", and "--port", etc. options are considered the
+ master; the second belongs to the slave.
+Byte values should be based on the volume of transactions needed to have the streaming replication
+disconnect from the master because of too much lag, determined by the Postgres configuration variable
+B<wal_keep_segments>. For units of time, valid units are 'seconds', 'minutes', 'hours', or 'days'.
+Each may be written singular or abbreviated to just the first letter. When specifying both, in the
+form 'I<bytes> and I<time>', both conditions must be true for the threshold to be met.
+
+You must provide information on how to reach the databases by providing a comma separated list to the
+--dbost and --dbport parameters, such as "--dbport=5432,5543". If not given, the action fails.
+
+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'
+
+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'
+
+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'
+
=head2 B<index_size>
=head2 B<table_size>
use lib 't','.';
use CP_Testing;
--use vars qw/$dbh $result $t $host $dbname/;
++use vars qw/$dbh $result $t $port $host $dbname/;
my $cp = CP_Testing->new( {default_action => 'txn_idle'} );
$dbh = $cp->test_database_handle();
$dbh->{AutoCommit} = 1;
--$dbname = $cp->get_dbname;
++$port = $cp->get_port();
$host = $cp->get_host();
++$dbname = $cp->get_dbname;
++
++diag "Connected as $port:$host:$dbname\n";
my $S = q{Action 'txn_idle'};
my $label = 'POSTGRES_TXN_IDLE';