Skip to content

Commit 735515a

Browse files
committed
hot_standby_delay: Check server version instead of psql version for features
In passing, make check_postgres.pl executable Close bucardo#74.
1 parent a3cf9da commit 735515a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

check_postgres.pl

100644100755
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,7 @@ sub verify_version {
30203020
}
30213021

30223022
$db->{slurp} = $oldslurp;
3023-
return;
3023+
return $sver;
30243024

30253025
} ## end of verify_version
30263026

@@ -5049,8 +5049,10 @@ sub check_hot_standby_delay {
50495049
## --warning=5min
50505050
## --warning='1048576 and 2min' --critical='16777216 and 10min'
50515051

5052+
my $version = verify_version();
5053+
50525054
my ($warning, $wtime, $critical, $ctime) = validate_integer_for_time({default_to_int => 1});
5053-
if ($psql_version < 9.1 and (length $wtime or length $ctime)) { # FIXME: check server version instead
5055+
if ($version < 9.1 and (length $wtime or length $ctime)) {
50545056
add_unknown msg('hs-time-version');
50555057
return;
50565058
}
@@ -5090,7 +5092,7 @@ sub check_hot_standby_delay {
50905092

50915093
## On slave
50925094
$SQL = q{SELECT pg_last_xlog_receive_location() AS receive, pg_last_xlog_replay_location() AS replay};
5093-
if ($psql_version >= 9.1) {
5095+
if ($version >= 9.1) {
50945096
$SQL .= q{, COALESCE(ROUND(EXTRACT(epoch FROM now() - pg_last_xact_replay_timestamp())),0) AS seconds};
50955097
}
50965098
my $info = run_command($SQL, { dbnumber => $slave, regex => qr/\// });
@@ -5149,7 +5151,7 @@ sub check_hot_standby_delay {
51495151
return;
51505152
}
51515153

5152-
$MRTG and do_mrtg($psql_version >= 9.1 ?
5154+
$MRTG and do_mrtg($version >= 9.1 ?
51535155
{one => $rep_delta, two => $rec_delta, three => $time_delta} :
51545156
{one => $rep_delta, two => $rec_delta});
51555157

@@ -5161,14 +5163,14 @@ sub check_hot_standby_delay {
51615163
$db->{perf} .= sprintf ' %s=%s;%s;%s',
51625164
perfname(msg('hs-receive-delay')), $rec_delta, $warning, $critical;
51635165
}
5164-
if ($psql_version >= 9.1) {
5166+
if ($version >= 9.1) {
51655167
$db->{perf} .= sprintf ' %s=%s;%s;%s',
51665168
perfname(msg('hs-time-delay')), $time_delta, $wtime, $ctime;
51675169
}
51685170

51695171
## Do the check on replay delay in case SR has disconnected because it way too far behind
51705172
my $msg = qq{$rep_delta};
5171-
if ($psql_version >= 9.1) {
5173+
if ($version >= 9.1) {
51725174
$msg .= qq{ and $time_delta seconds}
51735175
}
51745176
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)) {

0 commit comments

Comments
 (0)