enhance indent
This commit is contained in:
parent
069dfd3b2d
commit
7782a66d81
|
@ -76,20 +76,19 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'file-health:s' => { name => 'file_health' },
|
||||||
"file-health:s" => { name => 'file_health' },
|
'file-health-env:s' => { name => 'file_health_env' },
|
||||||
"file-health-env:s" => { name => 'file_health_env' },
|
# Email
|
||||||
# Email
|
'email-warning:s' => { name => 'email_warning' },
|
||||||
"email-warning:s" => { name => 'email_warning' },
|
'email-critical:s' => { name => 'email_critical' },
|
||||||
"email-critical:s" => { name => 'email_critical' },
|
'email-smtp-host:s' => { name => 'email_smtp_host' },
|
||||||
"email-smtp-host:s" => { name => 'email_smtp_host' },
|
'email-smtp-username:s' => { name => 'email_smtp_username' },
|
||||||
"email-smtp-username:s" => { name => 'email_smtp_username' },
|
'email-smtp-password:s' => { name => 'email_smtp_password' },
|
||||||
"email-smtp-password:s" => { name => 'email_smtp_password' },
|
'email-smtp-from:s' => { name => 'email_smtp_from' },
|
||||||
"email-smtp-from:s" => { name => 'email_smtp_from' },
|
'email-smtp-options:s@' => { name => 'email_smtp_options' },
|
||||||
"email-smtp-options:s@" => { name => 'email_smtp_options' },
|
'email-memory' => { name => 'email_memory' },
|
||||||
"email-memory" => { name => 'email_memory' },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
$self->{components_exec_load} = 0;
|
$self->{components_exec_load} = 0;
|
||||||
|
@ -218,19 +217,26 @@ sub send_email {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Email::Send::SMTP::Gmail',
|
centreon::plugins::misc::mymodule_load(
|
||||||
error_msg => "Cannot load module 'Email::Send::SMTP::Gmail'.");
|
output => $self->{output},
|
||||||
my ($mail, $error) = Email::Send::SMTP::Gmail->new(-smtp => $self->{option_results}->{email_smtp_host},
|
module => 'Email::Send::SMTP::Gmail',
|
||||||
%smtp_options);
|
error_msg => "Cannot load module 'Email::Send::SMTP::Gmail'."
|
||||||
|
);
|
||||||
|
my ($mail, $error) = Email::Send::SMTP::Gmail->new(
|
||||||
|
-smtp => $self->{option_results}->{email_smtp_host},
|
||||||
|
%smtp_options
|
||||||
|
);
|
||||||
if ($mail == -1) {
|
if ($mail == -1) {
|
||||||
$self->{output}->add_option_msg(short_msg => "session error: " . $error);
|
$self->{output}->add_option_msg(short_msg => "session error: " . $error);
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
my $result = $mail->send(-to => $smtp_to,
|
my $result = $mail->send(
|
||||||
-from => $self->{option_results}->{email_smtp_from},
|
-to => $smtp_to,
|
||||||
-subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject,
|
-from => $self->{option_results}->{email_smtp_from},
|
||||||
-body => $stdout,
|
-subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject,
|
||||||
-attachments => $self->{option_results}->{file_health} . ',' . $self->{option_results}->{file_health_env});
|
-body => $stdout,
|
||||||
|
-attachments => $self->{option_results}->{file_health} . ',' . $self->{option_results}->{file_health_env}
|
||||||
|
);
|
||||||
$mail->bye();
|
$mail->bye();
|
||||||
if ($result == -1) {
|
if ($result == -1) {
|
||||||
$self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "problem to send the email");
|
$self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "problem to send the email");
|
||||||
|
@ -291,4 +297,3 @@ The location of the environment storage file status (Should be something like: C
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
|
@ -98,22 +98,21 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'health-directory:s' => { name => 'health_directory' },
|
||||||
"health-directory:s" => { name => 'health_directory' },
|
'health-directory-pattern:s' => { name => 'health_directory_pattern' },
|
||||||
"health-directory-pattern:s" => { name => 'health_directory_pattern' },
|
'file-health-name:s' => { name => 'file_health_name', default => 'HealthCheck.log' },
|
||||||
"file-health-name:s" => { name => 'file_health_name', default => 'HealthCheck.log' },
|
'file-health-env-name:s' => { name => 'file_health_env_name', default => 'sympl_env_health.log' },
|
||||||
"file-health-env-name:s" => { name => 'file_health_env_name', default => 'sympl_env_health.log' },
|
# Email
|
||||||
# Email
|
'email-warning:s' => { name => 'email_warning' },
|
||||||
"email-warning:s" => { name => 'email_warning' },
|
'email-critical:s' => { name => 'email_critical' },
|
||||||
"email-critical:s" => { name => 'email_critical' },
|
'email-smtp-host:s' => { name => 'email_smtp_host' },
|
||||||
"email-smtp-host:s" => { name => 'email_smtp_host' },
|
'email-smtp-username:s' => { name => 'email_smtp_username' },
|
||||||
"email-smtp-username:s" => { name => 'email_smtp_username' },
|
'email-smtp-password:s' => { name => 'email_smtp_password' },
|
||||||
"email-smtp-password:s" => { name => 'email_smtp_password' },
|
'email-smtp-from:s' => { name => 'email_smtp_from' },
|
||||||
"email-smtp-from:s" => { name => 'email_smtp_from' },
|
'email-smtp-options:s@' => { name => 'email_smtp_options' },
|
||||||
"email-smtp-options:s@" => { name => 'email_smtp_options' },
|
'email-memory' => { name => 'email_memory' },
|
||||||
"email-memory" => { name => 'email_memory' },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
$self->{components_exec_load} = 0;
|
$self->{components_exec_load} = 0;
|
||||||
|
@ -216,7 +215,7 @@ sub send_email {
|
||||||
$send_email = 0 if ($status ne 'ok' && defined($prev_output) && $prev_output eq $subject);
|
$send_email = 0 if ($status ne 'ok' && defined($prev_output) && $prev_output eq $subject);
|
||||||
# recovery email
|
# recovery email
|
||||||
$send_email = 1 if ($status eq 'ok' && defined($prev_status) && $prev_status ne 'ok');
|
$send_email = 1 if ($status eq 'ok' && defined($prev_status) && $prev_status ne 'ok');
|
||||||
$self->{statefile_cache}->write(data => $self->{new_datas});
|
$self->{statefile_cache}->write(data => $self->{new_datas});
|
||||||
}
|
}
|
||||||
|
|
||||||
my $smtp_to = '';
|
my $smtp_to = '';
|
||||||
|
@ -237,19 +236,26 @@ sub send_email {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Email::Send::SMTP::Gmail',
|
centreon::plugins::misc::mymodule_load(
|
||||||
error_msg => "Cannot load module 'Email::Send::SMTP::Gmail'.");
|
output => $self->{output},
|
||||||
my ($mail, $error) = Email::Send::SMTP::Gmail->new(-smtp => $self->{option_results}->{email_smtp_host},
|
module => 'Email::Send::SMTP::Gmail',
|
||||||
%smtp_options);
|
error_msg => "Cannot load module 'Email::Send::SMTP::Gmail'."
|
||||||
|
);
|
||||||
|
my ($mail, $error) = Email::Send::SMTP::Gmail->new(
|
||||||
|
-smtp => $self->{option_results}->{email_smtp_host},
|
||||||
|
%smtp_options
|
||||||
|
);
|
||||||
if ($mail == -1) {
|
if ($mail == -1) {
|
||||||
$self->{output}->add_option_msg(short_msg => "session error: " . $error);
|
$self->{output}->add_option_msg(short_msg => "session error: " . $error);
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
my $result = $mail->send(-to => $smtp_to,
|
my $result = $mail->send(
|
||||||
-from => $self->{option_results}->{email_smtp_from},
|
-to => $smtp_to,
|
||||||
-subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject,
|
-from => $self->{option_results}->{email_smtp_from},
|
||||||
-body => $stdout,
|
-subject => defined($smtp_options{-subject}) ? $smtp_options{-subject} : $subject,
|
||||||
-attachments => $self->{option_results}->{file_health} . "," . $self->{option_results}->{file_health_env});
|
-body => $stdout,
|
||||||
|
-attachments => $self->{option_results}->{file_health} . "," . $self->{option_results}->{file_health_env}
|
||||||
|
);
|
||||||
$mail->bye();
|
$mail->bye();
|
||||||
if ($result == -1) {
|
if ($result == -1) {
|
||||||
$self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "problem to send the email");
|
$self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "problem to send the email");
|
||||||
|
@ -318,4 +324,3 @@ Name of the environment storage file status (Default: sympl_env_health.log).
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
Loading…
Reference in New Issue