summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Sabino Mullane2011-07-27 15:17:17 +0000
committerGreg Sabino Mullane2011-07-27 15:17:17 +0000
commitf602229720a7188c7ac12c7f2306b9468c8aa2c3 (patch)
treec76ec342601ee9fbb08602fddc187dfd71aae3b8
parent978a1814edd9f3add76f38806748e28956b56620 (diff)
New option "replace" to allow replacing the audit file after a run.
-rwxr-xr-xcheck_postgres.pl18
1 files changed, 18 insertions, 0 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index d67f7b833..1bff18961 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -959,6 +959,7 @@ GetOptions(
'schema=s@', ## used by slony_status only
'filter=s@', ## used by same_schema only
'suffix=s', ## used by same_schema only
+ 'replace', ## used by same_schema only
);
die $USAGE if ! keys %opt and ! @ARGV;
@@ -6189,6 +6190,23 @@ sub check_same_schema {
## Set the total time
$db->{totaltime} = sprintf '%.2f', tv_interval($start);
+ ## Before we outpu any results, rewrite the audit file if needed
+ ## We do this if we are reading from a saved file,
+ ## and the "replace" argument is set
+ if ($samedb and $opt{replace}) {
+ my $filename = audit_filename();
+ if ( -e $filename) {
+ ## Move the old one to a backup version
+ my $backupfile = "$filename.backup";
+ rename $filename, $backupfile;
+ }
+ my $version = $dbver{1}{version};
+ write_audit_file({ file => $filename, 'same_schema' => 1,
+ info => $thing{1}, pgversion => $version });
+ ## Cannot print this message as we are outputting Nagios stuff
+ #print msg('ss-createfile', $filename) . "\n";
+ }
+
## Comparison is done, let's report the results
if (! $opt{failcount}) {
add_ok msg('ss-matched');