From 6c86ff60ee9afdaae0aa35f8607f738e5455e4be Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 17 Jun 2016 14:47:44 +0200 Subject: [PATCH] + enhance emc symmetrix --- .../emc/symmetrix/dmx34/local/mode/hardware.pm | 17 ++++++++++++----- .../emc/symmetrix/vmax/local/mode/hardware.pm | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/storage/emc/symmetrix/dmx34/local/mode/hardware.pm b/storage/emc/symmetrix/dmx34/local/mode/hardware.pm index 7e08ede6b..010a6a303 100644 --- a/storage/emc/symmetrix/dmx34/local/mode/hardware.pm +++ b/storage/emc/symmetrix/dmx34/local/mode/hardware.pm @@ -153,10 +153,6 @@ sub send_email { } if (defined($self->{option_results}->{email_smtp_username}) && defined($self->{option_results}->{email_smtp_password})) { $smtp_options{-pass} = $self->{option_results}->{email_smtp_password}; - } - foreach my $option (@{$self->{option_results}->{email_smtp_options}}) { - next if ($option !~ /^(.+?)=(.+)$/); - $smtp_options{-$1} = $2; } ####### @@ -172,6 +168,17 @@ sub send_email { my $subject = $1; my $status = lc($self->{output}->get_litteral_status()); + foreach my $option (@{$self->{option_results}->{email_smtp_options}}) { + next if ($option !~ /^(.+?)=(.+)$/); + my ($label, $value) = ($1, $2); + if ($label =~ /subject/i) { + $value =~ s/%\{status\}/$status/g; + $value =~ s/%\{short_msg\}/$subject/g; + $label = lc($label); + } + $smtp_options{-$label} = $value; + } + my $send_email = 0; $send_email = 1 if ($status ne 'ok'); ####### @@ -216,7 +223,7 @@ sub send_email { } my $result = $mail->send(-to => $smtp_to, -from => $self->{option_results}->{email_smtp_from}, - -subject => $subject, + -subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject, -body => $stdout, -attachments => $self->{option_results}->{file_health} . ',' . $self->{option_results}->{file_health_env}); $mail->bye(); diff --git a/storage/emc/symmetrix/vmax/local/mode/hardware.pm b/storage/emc/symmetrix/vmax/local/mode/hardware.pm index fb9a893be..e8134bf2a 100644 --- a/storage/emc/symmetrix/vmax/local/mode/hardware.pm +++ b/storage/emc/symmetrix/vmax/local/mode/hardware.pm @@ -179,10 +179,6 @@ sub send_email { if (defined($self->{option_results}->{email_smtp_username}) && defined($self->{option_results}->{email_smtp_password})) { $smtp_options{-pass} = $self->{option_results}->{email_smtp_password}; } - foreach my $option (@{$self->{option_results}->{email_smtp_options}}) { - next if ($option !~ /^(.+?)=(.+)$/); - $smtp_options{-$1} = $2; - } ####### # Get current data @@ -197,6 +193,17 @@ sub send_email { my $subject = $1; my $status = lc($self->{output}->get_litteral_status()); + foreach my $option (@{$self->{option_results}->{email_smtp_options}}) { + next if ($option !~ /^(.+?)=(.+)$/); + my ($label, $value) = ($1, $2); + if ($label =~ /subject/i) { + $value =~ s/%\{status\}/$status/g; + $value =~ s/%\{short_msg\}/$subject/g; + $label = lc($label); + } + $smtp_options{-$label} = $value; + } + my $send_email = 0; $send_email = 1 if ($status ne 'ok'); ####### @@ -241,7 +248,7 @@ sub send_email { } my $result = $mail->send(-to => $smtp_to, -from => $self->{option_results}->{email_smtp_from}, - -subject => $subject, + -subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject, -body => $stdout, -attachments => $self->{option_results}->{file_health} . "," . $self->{option_results}->{file_health_env}); $mail->bye();