From a182f68d1913344b5afcc200a3828490365bd21d Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Fri, 2 May 2008 09:53:48 -0400 Subject: [PATCH] Fix problem with dbpass defined but no length Better initial debug output for psql location and version. --- check_postgres.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index e53ec5467..f76b70578 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -278,7 +278,9 @@ if (! defined $PSQL or ! length $PSQL) { -x $PSQL or ndie qq{The file "$PSQL" does not appear to be executable\n}; $res = qx{$PSQL --version}; $res =~ /^psql \(PostgreSQL\) (\d+\.\d+)/ or ndie qq{Could not determine psql version\n}; -my $psql_version = int $1; +my $psql_version = $1; + +$VERBOSE >= 1 and warn qq{psql=$PSQL version=$psql_version\n}; $opt{defaultdb} = $psql_version >= 7.4 ? 'postgres' : 'template1'; @@ -770,7 +772,7 @@ sub run_command { } push @args => '-p', $db->{port}; - if (defined $db->{dbpass}) { + if (defined $db->{dbpass} and length $db->{dbpass}) { ## Make a custom PGPASSFILE. Far better to simply use your own .pgpass of course ($passfh,$passfile) = tempfile('nagios.XXXXXXXX', SUFFIX => '.tmp', DIR => $tempdir); $VERBOSE >= 3 and warn "Created temporary pgpass file $passfile\n"; -- 2.30.2