diff --git a/MYMETA.json b/MYMETA.json index d0e7d4e..5aa209e 100644 --- a/MYMETA.json +++ b/MYMETA.json @@ -4,7 +4,7 @@ "unknown" ], "dynamic_config" : 0, - "generated_by" : "Module::Build version 0.4224", + "generated_by" : "Module::Build version 0.4231", "license" : [ "perl_5" ], @@ -50,5 +50,5 @@ ] }, "version" : "0.002", - "x_serialization_backend" : "JSON::PP version 2.97001" + "x_serialization_backend" : "JSON::PP version 4.02" } diff --git a/MYMETA.yml b/MYMETA.yml index d507fb5..535eaf3 100644 --- a/MYMETA.yml +++ b/MYMETA.yml @@ -4,7 +4,7 @@ author: - unknown build_requires: {} dynamic_config: 0 -generated_by: 'Module::Build version 0.4224, CPAN::Meta::Converter version 2.150010' +generated_by: 'Module::Build version 0.4231, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html diff --git a/doc/schema.mysql b/doc/schema.mysql index 09ab2a4..19f5559 100644 --- a/doc/schema.mysql +++ b/doc/schema.mysql @@ -61,6 +61,7 @@ CREATE TABLE `filesets` ( `dir` text, `options` text, active tinyint not null default 1, + timeout int, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; diff --git a/lib/Simba/CA.pm b/lib/Simba/CA.pm index 9546367..5907630 100644 --- a/lib/Simba/CA.pm +++ b/lib/Simba/CA.pm @@ -12,7 +12,7 @@ This class represents one instance of a running collecting agent. The only user-callable methods are the constructor new and the instance method run, which collects all the files from various disk agents. -The Simba::CA package is a hashref with the following keys: +The Simba::CA object is a hashref with the following keys: =over @@ -30,6 +30,8 @@ The Simba::CA package is a hashref with the following keys: =item targets +A list of entries (hashes) from table filesets. + =item ssh_id_file =item target @@ -50,6 +52,10 @@ The Simba::CA package is a hashref with the following keys: =item file_dfd +=item start_time + +Timestamp when the backup of the current target started. Used to test when to abort due to timeout. + =back =cut @@ -208,6 +214,7 @@ sub backup2disk { $self->log(3, "starting backup for target host " . $target->{host} . " dir " . $target->{dir}); $self->{target} = $target; + $self->{start_time} = time(); # get previous generation $self->get_last_session(); @@ -226,6 +233,15 @@ sub backup2disk { close($list_cfd); my $count = 0; while (<$list_dfd>) { + if ($target->{timeout}) { + my $now = time(); + my $elapsed = $now - $self->{start_time}; + $self->log(10, "checking timeout " . $elapsed . " > " . $target->{timeout}); + if ($elapsed > $target->{timeout}) { + $self->log(3, "Timeout exceeded. $elapsed > $target->{timeout}"); + last; + } + } $count++; chomp; $self->log(10, "file: $_");