From: Greg Sabino Mullane Date: Thu, 23 Oct 2008 20:15:35 +0000 (-0400) Subject: Minor tweak to storage of default port. X-Git-Tag: 2.9.0~216 X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=861dc99d951d3e2bbda9c8c894bd0948814a6678;p=check_postgres.git Minor tweak to storage of default port. --- diff --git a/check_postgres.pl b/check_postgres.pl index 70a5d2021..39f2076e1 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -28,9 +28,7 @@ $Data::Dumper::Varname = 'POSTGRES'; $Data::Dumper::Indent = 2; $Data::Dumper::Useqq = 1; -our $VERSION = '2.3.8'; - -our $DEF_PGPORT = 5432; +our $VERSION = '2.3.9'; use vars qw/ %opt $PSQL $res $COM $SQL $db /; @@ -50,6 +48,9 @@ $opt{showtime} = 1; ## Which user to connect as if --dbuser is not given $opt{defaultuser} = 'postgres'; +## Which port to connect to if --dbport is not given +$opt{defaultport} = 5432; + ## If true, we show "after the pipe" statistics $opt{showperf} = 1; @@ -239,9 +240,9 @@ 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 $DEF_PGPORT. + -p, --port=NUM port(s) to connect to; defaults to $opt{defaultport}. -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' + -u --dbuser=NAME database user(s) to connect as; defaults to '$opt{defaultuser}' --dbpass=PASS database password(s); use a .pgpass file instead when possible Connection options can be grouped: --host=a,b --host=c --port=1234 --port=3344 @@ -352,7 +353,7 @@ sub add_response { my $header = sprintf q{%s%s%s}, $action_info->{$action}[0] ? '' : qq{DB "$db->{dbname}" }, $db->{host} eq '' ? '' : qq{(host:$db->{host}) }, - $db->{port} eq $DEF_PGPORT ? '' : qq{(port=$db->{port}) }; + $db->{port} eq $opt{defaultport} ? '' : qq{(port=$db->{port}) }; $header =~ s/\s+$//; my $perf = ($opt{showtime} and $db->{totaltime}) ? "time=$db->{totaltime}" : ''; if ($db->{perf}) { @@ -838,7 +839,7 @@ sub run_command { my $conn = { host => [''], - port => [$DEF_PGPORT], + port => [$opt{defaultport}], dbname => [$opt{defaultdb}], dbuser => [$opt{defaultuser}], dbpass => [''], @@ -3594,7 +3595,7 @@ sub check_sequence { =head1 NAME B - a Postgres monitoring script for Nagios, MRTG, and others -This documents describes check_postgres.pl version 2.3.8 +This documents describes check_postgres.pl version 2.3.9 =head1 SYNOPSIS @@ -4738,6 +4739,10 @@ Items not specifically attributed are by Greg Sabino Mullane. =over 4 +=item B + + Minor tweak to way we store the default port. + =item B Allow the default port to be changed easily.