Add no-check_postgresrc option.
authorGreg Sabino Mullane <greg@endpoint.com>
Wed, 12 Aug 2009 10:39:33 +0000 (06:39 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Wed, 12 Aug 2009 10:39:33 +0000 (06:39 -0400)
check_postgres.pl

index bce5cd44f2b0fa0f2db2dc613d1139b3ab3d7c7c..827d37065fdbd47bac23760d0ae44b12517f6080 100755 (executable)
@@ -578,15 +578,25 @@ $opt{timeout} = 30;
 ## Command line options always overwrite these
 ## Format of these files is simply name=val
 
-my $rcfile;
-if (-e '.check_postgresrc') {
-       $rcfile = '.check_postgresrc';
-}
-elsif (-e "$ENV{HOME}/.check_postgresrc") {
-       $rcfile = "$ENV{HOME}/.check_postgresrc";
+## This option must come before the GetOptions call
+for my $arg (@ARGV) {
+       if ($arg eq '--no-check_postgresrc') {
+               $opt{'no-check_postgresrc'} = 1;
+               last;
+       }
 }
-elsif (-e '/etc/check_postgresrc') {
-       $rcfile = '/etc/check_postgresrc';
+
+my $rcfile;
+if (! $opt{'no-check_postgresrc'}) {
+       if (-e '.check_postgresrc') {
+               $rcfile = '.check_postgresrc';
+       }
+       elsif (-e "$ENV{HOME}/.check_postgresrc") {
+               $rcfile = "$ENV{HOME}/.check_postgresrc";
+       }
+       elsif (-e '/etc/check_postgresrc') {
+               $rcfile = '/etc/check_postgresrc';
+       }
 }
 if (defined $rcfile) {
        open my $rc, '<', $rcfile or die qq{Could not open "$rcfile": $!\n};
@@ -648,6 +658,7 @@ die $USAGE unless
                           'test',
                           'symlinks',
                           'debugoutput=s',
+                          'no-check_postgresrc',
 
                           'action=s',
                           'warning=s',
@@ -7674,6 +7685,10 @@ Items not specifically attributed are by Greg Sabino Mullane.
 
 =over 4
 
+=item B<Version 2.11.0>
+
+  Add the --no-check_postgresrc flag.
+
 =item B<Version 2.10.1>
 
   Add Nagios perf output to the wal_files check (Cédric Villemain)