seems to work
authorHeiko Schlittermann (root@keller) <hs@schlittermann.de>
Fri, 10 Jan 2014 10:53:21 +0100
changeset 2 7b9bad9c85e6
parent 1 1ea5da2535d7
child 3 71a0c4bd43b1
child 4 da08b2a30e06
seems to work
check
--- a/check	Thu Jan 09 22:55:25 2014 +0100
+++ b/check	Fri Jan 10 10:53:21 2014 +0100
@@ -16,8 +16,10 @@
 sub check_perms;
 sub config_names;
 sub get_devices;
+
 sub amchecks;
 sub amlists;
+
 sub main;
 
 my $NAME = 'AMANDA-CLIENT';
@@ -145,16 +147,38 @@
 	return @configs;
 };
 
+sub _amcheck {
+	#config: daily
+	#CHECKING
+	#
+	#Amanda Backup Client Hosts Check
+	#--------------------------------
+	#Client check: 1 host checked in 2.242 seconds.  0 problems found.
+	#
+	#(brought to you by Amanda 3.3.1)
+	#The check is finished
+
+	my $conf = shift;
+	my $_ = qx(amdump_client --config '$conf' check 2>&1);
+	/^config:\s+$conf\n
+		 CHECKING\n
+		 .*\n
+		 Client.check:.1.host.checked.in.\d+\.\d+.seconds\.\s+0.problems.found\.\n
+		 .*\n
+		 The.check.is.finished$
+	/smx or die "unexpected output from check:\n$_";
+}
+
 sub amchecks {
-	my @errors;
+	my @errors = ();
 	foreach my $conf (@_) {
-		push @errors, map { "$conf: $_" } grep { /^error/i } qx(amdump_client --config '$conf' check 2>&1);
+		eval { _amcheck $conf } or push @errors, $@;
 	}
-	die join "\n", @errors if @errors;
+	die @errors if @errors;
 	return 1;
 }
 
-sub amlist {
+sub _amlist {
 	# return a list of [ name, dev ] tupels.
 	# name: the name of the disk/device
 	# dev:  the local device id (stat)[0]
@@ -173,7 +197,7 @@
 	my %missing;
 
 	foreach my $conf (@confs) {
-		my @dles = amlist $conf;
+		my @dles = _amlist $conf;
 		foreach my $candidate (@candidates) {
 			# we're satisfied if either the name of the device is in
 			# the disklist, or the device id is found