[check_postgres] [commit] Make spaces in dirs by default.

check_postgres at bucardo.org check_postgres at bucardo.org
Tue Apr 28 15:31:09 UTC 2009


Committed by Greg Sabino Mullane <greg at endpoint.com>

Make spaces in dirs by default.

---
 check_postgres.pl |    4 ++--
 t/02_checkpoint.t |   14 +++++++-------
 t/CP_Testing.pm   |   14 +++++++-------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/check_postgres.pl b/check_postgres.pl
index abb4d46..8581d35 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -4334,7 +4334,7 @@ sub check_checkpoint {
 	## Checks how long in seconds since the last checkpoint on a WAL slave
 	## Supports: Nagios, MRTG
 	## Warning and critical are seconds
-	## Requires $ENV{PGATA} or --datadir
+	## Requires $ENV{PGDATA} or --datadir
 
 	my ($warning, $critical) = validate_range
 		({
@@ -4361,7 +4361,7 @@ sub check_checkpoint {
 		= $ENV{PGCONTROLDATA} ? $ENV{PGCONTROLDATA}
 		: $ENV{PGBINDIR}      ? "$ENV{PGBINDIR}/pg_controldata"
 		:                       'pg_controldata';
-	$COM = "$pgc $dir";
+	$COM = qq{$pgc "$dir"};
 	eval {
 		$res = qx{$COM 2>&1};
 	};
diff --git a/t/02_checkpoint.t b/t/02_checkpoint.t
index b345178..bff1210 100644
--- a/t/02_checkpoint.t
+++ b/t/02_checkpoint.t
@@ -39,29 +39,29 @@ like ($cp->run('-c 10 --datadir=foobar'), qr{ERROR: Invalid data_directory}, $t)
 
 my $host = $cp->get_host();
 $t=qq{$S fails when called against a non datadir datadir};
-like ($cp->run("-c 10 --datadir=$host"), qr{ERROR:.+could not read the given data directory}, $t);
+like ($cp->run(qq{-c 10 --datadir="$host"}), qr{ERROR:.+could not read the given data directory}, $t);
 
 $t=qq{$S works when called for a recent checkpoint};
 my $dbh = $cp->get_dbh();
 $dbh->do('CHECKPOINT');
 $dbh->commit();
 $host =~ s/socket$//;
-like ($cp->run("-w 20 --datadir=$host"), qr{POSTGRES_CHECKPOINT OK}, $t);
+like ($cp->run(qq{-w 20 --datadir="$host"}), qr{POSTGRES_CHECKPOINT OK}, $t);
 
 $t=qq{$S returns a warning when checkpoint older than warning option};
 sleep 2;
-like ($cp->run("-w 1 --datadir=$host"), qr{WARNING:}, $t);
+like ($cp->run(qq{-w 1 --datadir="$host"}), qr{WARNING:}, $t);
 
 $t=qq{$S returns a critical when checkpoint older than critical option};
-like ($cp->run("-c 1 --datadir=$host"), qr{CRITICAL:}, $t);
+like ($cp->run(qq{-c 1 --datadir="$host"}), qr{CRITICAL:}, $t);
 
 $t=qq{$S returns the correct number of seconds};
-like ($cp->run("-c 1 --datadir=$host"), qr{was \d seconds ago}, $t);
+like ($cp->run(qq{-c 1 --datadir="$host"}), qr{was \d seconds ago}, $t);
 
 $t=qq{$S returns the expected output for MRTG};
-like ($cp->run("-c 1 --output=MRTG --datadir=$host"), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
+like ($cp->run(qq{-c 1 --output=MRTG --datadir="$host"}), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
 
 $t=qq{$S returns the expected output for MRTG};
-like ($cp->run("-c 199 --output=MRTG --datadir=$host"), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
+like ($cp->run(qq{-c 199 --output=MRTG --datadir="$host"}), qr{^\d\n0\n\nLast checkpoint was \d seconds ago}, $t);
 
 exit;
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index f028087..e7d4f7b 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -33,7 +33,7 @@ sub cleanup {
 
 	my $self = shift;
 	my $dbdir = $self->{dbdir} or die;
-	my $pidfile = "$dbdir/data/postmaster.pid";
+	my $pidfile = "$dbdir/data space/postmaster.pid";
 	return if ! -e $pidfile;
 	open my $fh, '<', $pidfile or die qq{Could not open "$pidfile": $!\n};
 	<$fh> =~ /^(\d+)/ or die qq{File "$pidfile" did not start with a number!\n};
@@ -72,7 +72,7 @@ sub test_database_handle {
 			: $ENV{PGBINDIR} ? "$ENV{PGBINDIR}/initdb"
 			:                  'initdb';
 
-		$com = qq{LC_ALL=en LANG=C $initdb --locale=C -E UTF8 -D $dbdir/data 2>&1};
+		$com = qq{LC_ALL=en LANG=C $initdb --locale=C -E UTF8 -D "$dbdir/data space" 2>&1};
 		eval {
 			$info = qx{$com};
 		};
@@ -81,7 +81,7 @@ sub test_database_handle {
 		}
 
 		## Modify the postgresql.conf
-		my $cfile = "$dbdir/data/postgresql.conf";
+		my $cfile = "$dbdir/data space/postgresql.conf";
 		open my $cfh, '>>', $cfile or die qq{Could not open "$cfile": $!\n};
 		print $cfh qq{\n\n## check_postgres.pl testing parameters\n};
 		print $cfh qq{listen_addresses = ''\n};
@@ -91,14 +91,14 @@ sub test_database_handle {
 		print $cfh "\n";
 		close $cfh or die qq{Could not close "$cfile": $!\n};
 
-		mkdir "$dbdir/data/socket";
+		mkdir "$dbdir/data space/socket";
 
 	}
 
 	## See if the database is already running.
 	my $needs_startup = 0;
 
-	my $pidfile = "$dbdir/data/postmaster.pid";
+	my $pidfile = "$dbdir/data space/postmaster.pid";
 	if (! -e $pidfile) {
 		$needs_startup = 1;
 	}
@@ -127,7 +127,7 @@ sub test_database_handle {
 			: $ENV{PGBINDIR} ? "$ENV{PGBINDIR}/pg_ctl"
 			:                  'pg_ctl';
 
-		$com = qq{LC_ALL=en LANG=C $pg_ctl -o '-k socket' -l $logfile -D "$dbdir/data" start};
+		$com = qq{LC_ALL=en LANG=C $pg_ctl -o '-k socket' -l $logfile -D "$dbdir/data space" start};
 		eval {
 			$info = qx{$com};
 		};
@@ -156,7 +156,7 @@ sub test_database_handle {
 	} ## end of needs startup
 
 	my $here = cwd();
-	my $dbhost = $self->{dbhost} = "$here/$dbdir/data/socket";
+	my $dbhost = $self->{dbhost} = "$here/$dbdir/data space/socket";
 	$dbhost =~ s/^ /\\ /;
 	$dbhost =~ s/([^\\]) /$1\\ /g;
 	$self->{dbname} ||= 'postgres';
-- 
1.6.0.5



More information about the Check_postgres mailing list