Fix the archive_ready action
authorNicolas Thauvin <[email protected]>
Mon, 27 Jun 2011 14:55:06 +0000 (16:55 +0200)
committerGuillaume Lelarge <[email protected]>
Mon, 27 Jun 2011 14:59:27 +0000 (16:59 +0200)
The .ready files are not in the pg_xlog directory, but in the
pg_xlog/archive_ready one. This patch adds another argument to the
check_wal_files() function so that it could find the subdirectory in which it
has to look for files.

check_postgres.pl

index d4d224ccdf286e64f3c8ae4b6fc4f7273cd011bf..847a17a75412a6e3ba67047f80cc0130e40c13dd 100755 (executable)
@@ -2817,7 +2817,7 @@ sub check_archive_ready {
     ## Critical and warning are the number of files
     ## Example: --critical=10
 
-    return check_wal_files('.ready');
+    return check_wal_files('/archive_status', '.ready');
 
 } ## end of check_archive_ready
 
@@ -7805,12 +7805,13 @@ sub check_wal_files {
     ## Critical and warning are the number of files
     ## Example: --critical=40
 
+    my $subdir = shift || '';
     my $extrabit = shift || '';
 
     my ($warning, $critical) = validate_range({type => 'positive integer', leastone => 1});
 
     ## Figure out where the pg_xlog directory is
-    $SQL = qq{SELECT count(*) AS count FROM pg_ls_dir('pg_xlog') WHERE pg_ls_dir ~ E'^[0-9A-F]{24}$extrabit$'}; ## no critic (RequireInterpolationOfMetachars)
+    $SQL = qq{SELECT count(*) AS count FROM pg_ls_dir('pg_xlog$subdir') WHERE pg_ls_dir ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars)
 
     my $info = run_command($SQL, {regex => qr[\d] });