[check_postgres] Reverse hot_standby_delay Hosts

David E. Wheeler david at kineticode.com
Mon May 16 22:42:31 UTC 2011


Nagiosians,

One of our clients complained that, when he reversed host 1 and host 2 in the host_standby_delay task, while it nicely figures out which is the master and which is the slave, the output could be confusing:

POSTGRES_HOT_STANDBY_DELAY OK: (host:slave => master) 0 | time=0.02 replay_delay=0;5; receive_delay=0;5; 

So I fixed it. The following patch will reverse the order of the hosts in $opt if they're entered backwards. So now it will always say:

POSTGRES_HOT_STANDBY_DELAY OK: (host:master => slave) 0 | time=0.02 replay_delay=0;5; receive_delay=0;5; 

Thanks,

David

diff --git a/check_postgres.pl b/check_postgres.pl
index 41c99bc..2124216 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -4035,6 +4035,14 @@ sub check_hot_standby_delay {
         return;
     }
 
+    if ($slave == 1) {
+        # Reverse stuff.
+        ($slave, $master) = (2, 1);
+        for my $k (qw(host port dbname dbuser dbpass)) {
+            ($opt{$k}, $opt{$k . 2}) = ($opt{$k . 2}, $opt{$k});
+        }
+    }
+
     ## Get xlog positions
     my ($moffset, $s_rec_offset, $s_rep_offset);
     ## On master



More information about the Check_postgres mailing list