Allow for default port to be changed easily.
authorGreg Sabino Mullane <[email protected]>
Wed, 22 Oct 2008 02:27:01 +0000 (22:27 -0400)
committerGreg Sabino Mullane <[email protected]>
Wed, 22 Oct 2008 02:27:01 +0000 (22:27 -0400)
check_postgres.pl

index 4cc1cd1f69fdaf5b6ce2bd7b473835f4f6939430..ab554b07d6d9c1e23932af144d77f3442ab62c4c 100755 (executable)
@@ -28,7 +28,9 @@ $Data::Dumper::Varname = 'POSTGRES';
 $Data::Dumper::Indent = 2;
 $Data::Dumper::Useqq = 1;
 
-our $VERSION = '2.3.7';
+our $VERSION = '2.3.8';
+
+our $DEF_PGPORT = 5432;
 
 use vars qw/ %opt $PSQL $res $COM $SQL $db /;
 
@@ -228,7 +230,7 @@ This is version $VERSION.
 
 Common connection options:
  -H,  --host=NAME    hostname(s) to connect to; defaults to none (Unix socket)
- -p,  --port=NUM     port(s) to connect to; defaults to 5432.
+ -p,  --port=NUM     port(s) to connect to; defaults to $DEF_PGPORT.
  -db, --dbname=NAME  database name(s) to connect to; defaults to 'postgres' or 'template1'
  -u   --dbuser=NAME  database user(s) to connect as; defaults to 'postgres'
       --dbpass=PASS  database password(s); use a .pgpass file instead when possible
@@ -341,7 +343,7 @@ sub add_response {
        my $header = sprintf q{%s%s%s},
                $action_info->{$action}[0] ? '' : qq{DB "$db->{dbname}" },
                        $db->{host} eq '<none>' ? '' : qq{(host:$db->{host}) },
-                               $db->{port} eq '5432' ? '' : qq{(port=$db->{port}) };
+                               $db->{port} eq $DEF_PGPORT ? '' : qq{(port=$db->{port}) };
        $header =~ s/\s+$//;
        my $perf = $opt{showtime} ? "time=$db->{totaltime}" : '';
        if ($db->{perf}) {
@@ -812,7 +814,7 @@ sub run_command {
        my $conn =
                {
                 host   => ['<none>'],
-                port   => [5432],
+                port   => [$DEF_PGPORT],
                 dbname => [$opt{defaultdb}],
                 dbuser => [$opt{defaultuser}],
                 dbpass => [''],