summaryrefslogtreecommitdiff
path: root/check_postgres.pl
diff options
context:
space:
mode:
authorGreg Sabino Mullane2009-08-12 11:42:53 +0000
committerGreg Sabino Mullane2009-08-12 11:42:53 +0000
commite375c8631cd6cafa3cc235f643a7d6230a632cd5 (patch)
treefd9e259b274dda6ba5f98aa3c945556845c93716 /check_postgres.pl
parentca96bf01dd959982f04d0976c62be40fff5529af (diff)
Ensure command-line overrides check_postgresrc entries
Diffstat (limited to 'check_postgres.pl')
-rwxr-xr-xcheck_postgres.pl16
1 files changed, 12 insertions, 4 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index 57c6b9cc3..bc54bd548 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -598,6 +598,8 @@ if (! $opt{'no-check_postgresrc'}) {
$rcfile = '/etc/check_postgresrc';
}
}
+## We need a temporary hash so that multi-value options can be overriden on the command line
+my %tempopt;
if (defined $rcfile) {
open my $rc, '<', $rcfile or die qq{Could not open "$rcfile": $!\n};
RCLINE:
@@ -633,10 +635,10 @@ if (defined $rcfile) {
## These options are multiples ('@s')
for my $arr (qw/include exclude includeuser excludeuser host port dbuser dbname dbpass dbservice/) {
- if ($name eq $arr or $name eq "${arr}2") {
- push @{$opt{$name}} => $value;
- next RCLINE;
- }
+ next if $name ne $arr and $name ne "${arr}2";
+ push @{$tempopt{$name}} => $value;
+ ## Don't set below as a normal value
+ next RCLINE;
}
$opt{$name} = $value;
}
@@ -699,6 +701,11 @@ die $USAGE unless
and keys %opt
and ! @ARGV;
+## Put multi-val options from check_postgresrc in place, only if no command-line args!
+for my $mv (keys %tempopt) {
+ $opt{$mv} ||= delete $tempopt{$mv};
+}
+
our $VERBOSE = $opt{verbose} || 0;
our $OUTPUT = lc $opt{output} || '';
@@ -7701,6 +7708,7 @@ Items not specifically attributed are by Greg Sabino Mullane.
=item B<Version 2.11.0>
Add the --no-check_postgresrc flag.
+ Ensure check_postgresrc options are completely overriden by command-line options.
=item B<Version 2.10.1>