added the new option 'subject_prefix' in 'emailreports.pm' to be able to set a customized prefix in the Subject of the emails that will be sent

This commit is contained in:
Jordi Sanfeliu 2019-05-17 12:13:19 +02:00
parent 3c1b2602a3
commit 252a843ca6
3 changed files with 13 additions and 1 deletions

View File

@ -12,6 +12,8 @@
- Added the new option 'rrdtool_extra_options' to be able to include RRDtool - Added the new option 'rrdtool_extra_options' to be able to include RRDtool
extra options on every graph. extra options on every graph.
(suggested by Greg Ogonowski, greg AT indexcom.com) (suggested by Greg Ogonowski, greg AT indexcom.com)
- Added the new option 'subject_prefix' in 'emailreports.pm' to be able to
set a customized prefix in the Subject of the emails that will be sent.
- Changed the main loop functionality using now the select() function, instead - Changed the main loop functionality using now the select() function, instead
of the alarm()+pause() pair. This should improve the responsiveness on high of the alarm()+pause() pair. This should improve the responsiveness on high
system loads. [#230] system loads. [#230]

View File

@ -38,6 +38,7 @@ sub emailreports_send {
my $imgs_dir = $config->{imgs_dir}; my $imgs_dir = $config->{imgs_dir};
my $images; my $images;
my $mime; my $mime;
my $subject;
logger("$myself: sending $report reports."); logger("$myself: sending $report reports.");
@ -175,6 +176,8 @@ EOF
$html .= $html_footer; $html .= $html_footer;
$subject = $emailreports->{subject_prefix} || "Monitorix:";
# create the multipart container and add attachments # create the multipart container and add attachments
foreach (split(',', $emailreports->{$report}->{to})) { foreach (split(',', $emailreports->{$report}->{to})) {
my $to = trim($_); my $to = trim($_);
@ -182,7 +185,7 @@ EOF
my $msg = new MIME::Lite( my $msg = new MIME::Lite(
From => $emailreports->{from_address}, From => $emailreports->{from_address},
To => $to, To => $to,
Subject => "Monitorix: '$report' Report", Subject => "$subject '$report' Report",
Type => "multipart/related", Type => "multipart/related",
Organization => "Monitorix", Organization => "Monitorix",
); );

View File

@ -3117,6 +3117,13 @@ This is the address that will be used as remitent for all the monthly report ema
Default value: \fInoreply@example.com\fP Default value: \fInoreply@example.com\fP
.RE .RE
.P .P
.BI subject_prefix
.RS
This is a string that will be prefixed in the Subject of all emails that will be sent.
.P
Default value: \fIMonitorix:\fP
.RE
.P
.BI hour .BI hour
.RS .RS
This is the hour (in 24h format) when the email reports will be sent. This is the hour (in 24h format) when the email reports will be sent.