aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Beaupré <anarcat@koumbit.org>2015-04-17 16:58:09 -0400
committerAntoine Beaupré <anarcat@koumbit.org>2015-04-17 16:59:10 -0400
commit559a8d65fc7a9b00a208219b7cda47749d2b4d68 (patch)
treee053aab216b1686f62f1459d1fffb529c67a6975
parent27b1b73d39009c17d17bae728d8634d67fd82f3c (diff)
downloadpuppet-backupninja-559a8d65fc7a9b00a208219b7cda47749d2b4d68.tar.gz
puppet-backupninja-559a8d65fc7a9b00a208219b7cda47749d2b4d68.tar.bz2
more refactoring
get rid of more temporary variables and cleanup
-rwxr-xr-xfiles/checkbackups.pl14
1 files changed, 6 insertions, 8 deletions
diff --git a/files/checkbackups.pl b/files/checkbackups.pl
index 2473218..aebd71a 100755
--- a/files/checkbackups.pl
+++ b/files/checkbackups.pl
@@ -56,6 +56,7 @@ sub check_rdiff {
my ($host, $dir, $subdir, $optv) = @_;
my $flag="$dir/$subdir/rdiff-backup-data/backup.log";
my $extra_msg = '';
+ my @vservers;
if (open(FLAG, $flag)) {
while (<FLAG>) {
if (/StartTime ([0-9]*).[0-9]* \((.*)\)/) {
@@ -65,7 +66,7 @@ sub check_rdiff {
}
}
if (!$last_bak) {
- $message = "cannot parse backup.log for a valid timestamp";
+ print_status($host, $STATE_UNKNOWN, "cannot parse backup.log for a valid timestamp");
next;
}
} else {
@@ -114,7 +115,7 @@ sub check_flag {
my ($host, $flag) = @_;
my @stats = stat($flag);
if (not @stats) {
- print_status($host, $state, "cannot stat flag $flag");
+ print_status($host, $STATE_UNKNOWN, "cannot stat flag $flag");
}
else {
($state, $delta) = check_age($stats[9]);
@@ -133,7 +134,7 @@ if (defined($opt_o)) {
}
chdir($backupdir);
-my ($delta, $state, $message, @vservers, $host);
+my ($delta, $state, $host);
foreach $host (@hosts) {
chomp($host);
if ($opt_o) {
@@ -142,9 +143,6 @@ foreach $host (@hosts) {
$dir = $host;
}
my $flag="";
- @vservers = ();
- $state = $STATE_UNKNOWN;
- $message = "???";
if (-d $dir) {
# guess the backup type and find a proper stamp file to compare
# XXX: the backup type should be part of the machine registry
@@ -166,9 +164,9 @@ foreach $host (@hosts) {
$flag="$dir/rsync.log";
check_flag($host, $flag);
} else {
- print_status($host, $state, 'unknown system');
+ print_status($host, $STATE_UNKNOWN, 'unknown system');
}
} else {
- print_status($host, $state, 'no directory');
+ print_status($host, $STATE_UNKNOWN, 'no directory');
}
}