X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=application-src%2Famlog-script.pl;h=b836758c9d4767e4aad2d7bfce84294de27964ee;hb=fd48f3e498442f0cbff5f3606c7c403d0566150e;hp=40dc3e6b1374cef10caa84e06720d243f0e60183;hpb=96f35b20267e8b1a1c846d476f27fcd330e0b018;p=debian%2Famanda diff --git a/application-src/amlog-script.pl b/application-src/amlog-script.pl index 40dc3e6..b836758 100644 --- a/application-src/amlog-script.pl +++ b/application-src/amlog-script.pl @@ -1,5 +1,5 @@ #!@PERL@ -# Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved. +# Copyright (c) 2008,2009 Zmanda, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as published @@ -14,7 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300 +# Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com use lib '@amperldir@'; @@ -33,8 +33,8 @@ use Amanda::Constants; sub new { my $class = shift; - my ($execute_where, $config, $host, $disk, $device, $level, $index, $message, $collection, $record, $logfile) = @_; - my $self = $class->SUPER::new($execute_where); + my ($execute_where, $config, $host, $disk, $device, $level, $index, $message, $collection, $record, $logfile, $text) = @_; + my $self = $class->SUPER::new($execute_where, $config); $self->{execute_where} = $execute_where; $self->{config} = $config; @@ -47,6 +47,7 @@ sub new { $self->{collection} = $collection; $self->{record} = $record; $self->{logfile} = $logfile; + $self->{text} = $text; return $self; } @@ -55,15 +56,19 @@ sub setup() { my $self = shift; if (!defined $self->{logfile}) { - $self->print_to_server_and_die($self->{action}, "property LOGFILE not set", $Amanda::Script_App::ERROR); + $self->print_to_server_and_die("property LOGFILE not set", + $Amanda::Script_App::ERROR); } my $dirname = File::Basename::dirname($self->{logfile}); if (! -e $dirname) { - $self->print_to_server_and_die($self->{action}, "Directory '$dirname' doesn't exist", $Amanda::Script_App::ERROR); + $self->print_to_server_and_die("Directory '$dirname' doesn't exist", + $Amanda::Script_App::ERROR); } if (! -d $dirname) { - $self->print_to_server_and_die($self->{action}, "Directory '$dirname' is not a directory", $Amanda::Script_App::ERROR); + $self->print_to_server_and_die( + "Directory '$dirname' is not a directory",i + $Amanda::Script_App::ERROR); } } @@ -83,7 +88,6 @@ sub command_support { sub command_pre_dle_amcheck { my $self = shift; - $self->{action} = "check"; $self->setup(); $self->log_data("pre-dle-amcheck"); } @@ -91,7 +95,6 @@ sub command_pre_dle_amcheck { sub command_pre_host_amcheck { my $self = shift; - $self->{action} = "check"; $self->setup(); $self->log_data("pre-host-amcheck"); } @@ -99,7 +102,6 @@ sub command_pre_host_amcheck { sub command_post_dle_amcheck { my $self = shift; - $self->{action} = "check"; $self->setup(); $self->log_data("post-dle-amcheck"); } @@ -107,7 +109,6 @@ sub command_post_dle_amcheck { sub command_post_host_amcheck { my $self = shift; - $self->{action} = "check"; $self->setup(); $self->log_data("post-host-amcheck"); } @@ -115,7 +116,6 @@ sub command_post_host_amcheck { sub command_pre_dle_estimate { my $self = shift; - $self->{action} = "estimate"; $self->setup(); $self->log_data("pre-dle-estimate"); } @@ -123,7 +123,6 @@ sub command_pre_dle_estimate { sub command_pre_host_estimate { my $self = shift; - $self->{action} = "estimate"; $self->setup(); $self->log_data("pre-host-estimate"); } @@ -131,7 +130,6 @@ sub command_pre_host_estimate { sub command_post_dle_estimate { my $self = shift; - $self->{action} = "estimate"; $self->setup(); $self->log_data("post-dle-estimate"); } @@ -139,7 +137,6 @@ sub command_post_dle_estimate { sub command_post_host_estimate { my $self = shift; - $self->{action} = "estimate"; $self->setup(); $self->log_data("post-host-estimate"); } @@ -147,7 +144,6 @@ sub command_post_host_estimate { sub command_pre_dle_backup { my $self = shift; - $self->{action} = "backup"; $self->setup(); $self->log_data("pre-dle-backup"); } @@ -155,7 +151,6 @@ sub command_pre_dle_backup { sub command_pre_host_backup { my $self = shift; - $self->{action} = "backup"; $self->setup(); $self->log_data("pre-host-backup"); } @@ -163,7 +158,6 @@ sub command_pre_host_backup { sub command_post_dle_backup { my $self = shift; - $self->{action} = "backup"; $self->setup(); $self->log_data("post-dle-backup"); } @@ -171,7 +165,6 @@ sub command_post_dle_backup { sub command_post_host_backup { my $self = shift; - $self->{action} = "backup"; $self->setup(); $self->log_data("post-host-backup"); } @@ -179,7 +172,6 @@ sub command_post_host_backup { sub command_pre_recover { my $self = shift; - $self->{action} = "restore"; $self->setup(); $self->log_data("pre-recover"); } @@ -187,7 +179,6 @@ sub command_pre_recover { sub command_post_recover { my $self = shift; - $self->{action} = "restore"; $self->setup(); $self->log_data("post-recover"); } @@ -195,7 +186,6 @@ sub command_post_recover { sub command_pre_level_recover { my $self = shift; - $self->{action} = "restore"; $self->setup(); $self->log_data("pre-level-recover"); } @@ -203,7 +193,6 @@ sub command_pre_level_recover { sub command_post_level_recover { my $self = shift; - $self->{action} = "restore"; $self->setup(); $self->log_data("post-level-recover"); } @@ -211,7 +200,6 @@ sub command_post_level_recover { sub command_inter_level_recover { my $self = shift; - $self->{action} = "restore"; $self->setup(); $self->log_data("inter-level-recover"); } @@ -221,8 +209,11 @@ sub log_data { my($function) = shift; my $log; - open($log, ">>$self->{logfile}") || $self->print_to_server_and_die($self->{action}, "Can't open logfile '$self->{logfile}' for append: $!", $Amanda::Script_App::ERROR); - print $log "$self->{config} $function $self->{execute_where} $self->{host} $self->{disk} $self->{device} ", join (" ", @{$self->{level}}), "\n"; + open($log, ">>$self->{logfile}") || + $self->print_to_server_and_die( + "Can't open logfile '$self->{logfile}' for append: $!", + $Amanda::Script_App::ERROR); + print $log "$self->{action} $self->{config} $function $self->{execute_where} $self->{host} $self->{disk} $self->{device} ", join (" ", @{$self->{level}}), " $self->{text}\n"; close $log; } @@ -246,6 +237,7 @@ my $opt_message; my $opt_collection; my $opt_record; my $opt_logfile; +my $opt_text; Getopt::Long::Configure(qw{bundling}); GetOptions( @@ -259,10 +251,11 @@ GetOptions( 'message=s' => \$opt_message, 'collection=s' => \$opt_collection, 'record=s' => \$opt_record, - 'logfile=s' => \$opt_logfile + 'logfile=s' => \$opt_logfile, + 'text=s' => \$opt_text ) or usage(); -my $script = Amanda::Script::amlog_script->new($opt_execute_where, $opt_config, $opt_host, $opt_disk, $opt_device, \@opt_level, $opt_index, $opt_message, $opt_collection, $opt_record, $opt_logfile); +my $script = Amanda::Script::amlog_script->new($opt_execute_where, $opt_config, $opt_host, $opt_disk, $opt_device, \@opt_level, $opt_index, $opt_message, $opt_collection, $opt_record, $opt_logfile, $opt_text); $script->do($ARGV[0]);