aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Beaupre <anarcat@koumbit.org>2009-04-17 13:01:54 -0400
committerAntoine Beaupre <anarcat@koumbit.org>2009-04-17 13:01:54 -0400
commit9aa5fb318ffe3bf976d4e456c2754ca6b97dc9e8 (patch)
tree46c267c5eec7ca1f1c172499eb82474ab380fc75
parent981c43068254a2c49a677bb7c66c61c5c0f99943 (diff)
downloadpuppet-backupninja-9aa5fb318ffe3bf976d4e456c2754ca6b97dc9e8.tar.gz
puppet-backupninja-9aa5fb318ffe3bf976d4e456c2754ca6b97dc9e8.tar.bz2
detect multiple vserver locations
-rwxr-xr-xfiles/checkbackups.pl25
1 files changed, 17 insertions, 8 deletions
diff --git a/files/checkbackups.pl b/files/checkbackups.pl
index adc4379..f46920b 100755
--- a/files/checkbackups.pl
+++ b/files/checkbackups.pl
@@ -35,6 +35,11 @@ my $STATE_CRITICAL=2;
my $STATE_UNKNOWN=3;
my $STATE_DEPENDENT=4;
+# gross hack: we look into subdirs to find vservers
+my @vserver_dirs = qw{/var/lib/vservers /vservers};
+# even worse: hardcode a suffix to the vserver name to get a FQDN
+my $dom_sufx = ".koumbit.net";
+
our $opt_d = "/backup";
our $opt_c = 48 * 60 * 60;
our $opt_w = 24 * 60 * 60;
@@ -55,12 +60,14 @@ my $warn = $opt_w;
my @hosts=qx{ls $backupdir};
chdir($backupdir);
-foreach my $host (@hosts) {
+my ($state, $message, @vservers, $host);
+foreach $host (@hosts) {
chomp($host);
my $flag="";
my $type="unknown";
- my @vservers = ();
- my $state = $STATE_UNKNOWN;
+ @vservers = ();
+ $state = $STATE_UNKNOWN;
+ $message = "???";
if (-d $host) {
# guess the backup type and find a proper stamp file to compare
# XXX: this doesn't check if the backup was actually successful
@@ -68,10 +75,12 @@ foreach my $host (@hosts) {
if (-d "$host/rdiff-backup") {
$flag="$host/rdiff-backup/rdiff-backup-data/backup.log";
$type="rdiff";
- $vserver_dir = "$host/rdiff-backup/var/lib/vservers";
- if (opendir(DIR, $vserver_dir)) {
- @vservers = grep { /^\./ && -f "$vserver_dir/$_" } readdir(DIR);
- closedir DIR;
+ foreach my $vserver_dir (@vserver_dirs) {
+ $dir = "$host/rdiff-backup$vserver_dir";
+ if (opendir(DIR, $dir)) {
+ @vservers = grep { /^[^\.]/ && -d "$dir/$_" } readdir(DIR);
+ closedir DIR;
+ }
}
} elsif (-d "$host/dump") {
$flag="$host/dump/" . `ls -tr $host/dump | tail -1`;
@@ -105,6 +114,6 @@ foreach my $host (@hosts) {
} continue {
printf "$host\tbackups\t$state\t$message\n";
foreach my $vserver (@vservers) {
- printf "$vserver\tbackups\t$state\t$message\n";
+ printf "$vserver$dom_sufx\tbackups\t$state\t$message\n";
}
}