[check_postgres] same_schema

Greg Sabino Mullane greg at endpoint.com
Wed Dec 9 20:08:20 UTC 2015


On Wed, Dec 09, 2015 at 09:02:53AM +0000, Strauß Fabian wrote:
> Is there an option to store the file in a different directory?

No, it simply writes to the current directory. I wrote a quick patch 
that should work, however, by allowing you to specify a writeable 
directory with the --audit-file-dir argument. Let us know how it 
works out.

-- 
Greg Sabino Mullane greg at endpoint.com
End Point Corporation
PGP Key: 0x14964AC8
-------------- next part --------------
diff --git a/check_postgres.pl b/check_postgres.pl
index 9dccaf0..202bdcb 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -22,6 +22,7 @@ use utf8;
 use Getopt::Long qw/GetOptions/;
 Getopt::Long::Configure(qw/ no_ignore_case pass_through  /);
 use File::Basename qw/basename/;
+use File::Spec;
 use File::Temp qw/tempfile tempdir/;
 File::Temp->safe_level( File::Temp::MEDIUM );
 use Cwd;
@@ -1228,6 +1229,7 @@ GetOptions(
     'PSQL=s',
 
     'tempdir=s',
+    'audit-file-dir=s',
     'get_method=s',
     'language=s',
     'mrtg=s',      ## used by MRTG checks only
@@ -6998,6 +7000,13 @@ sub audit_filename {
         $filename .= ".$opt{suffix}";
     }
 
+    ## Need to store in a separate directory?
+    my $adir = $opt{audit-file-dir};
+    if (defined $adir) {
+        -d $adir or die qq{Cannot write to directory "$adir": $!\n};
+        $filename = File::Spec->catfile($adir, $filename);
+    }
+
     return $filename;
 
 } ## end of audit_filename
@@ -9666,6 +9675,9 @@ becomes "database #2" and is compared to the current database.
 
 To replace the old stored file with the new version, use the --replace argument.
 
+If you need to write the stored file to a specific direectory, use 
+the --audit-file-dir argument.
+
 To enable snapshots at various points in time, you can use the "--suffix" 
 argument to make the filenames unique to each run. See the examples below.
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <https://mail.endcrypt.com/pipermail/check_postgres/attachments/20151209/e1503cea/attachment.sig>


More information about the Check_postgres mailing list