ldirectord: Allow sending email via external SMTP server
PATCH 1/1 ldirectord: Allow sending email via external SMTP server
Hello all,
Attached is a patch to ldirectord (version 1.186-ha-2.1.4) that adds a new configuration directive "smtp". This directive allows ldirectord to send notification emails via an external SMTP server instead of using the built-in Mail::Mailer methods. I wrote this patch because none of the methods in Mail::Mailer were convenient for use in our environment. However, we do run an enterprise wide SMTP relay for internal notifications, such as those generated by ldirectord. I would imagine many other organizations are in the same situation we are, and this would be a good addition to ldirectord.
Feel free to add/change/remove anything that doesn't seem right with the code.
Also, let me know if should post this to the Linux-HA development mailing list instead of here.
Thanks.
Caleb Anthony
tmp/ldirecord.new/ldirectord renamed from tmp/ldirecord.orig/ldirectord +43 -0
@@ -229,6 +229,13 @@ Default: all +B<smtp = >I<ip_address|hostname>B<"> + +A valid SMTP server address to use for sending email via SMTP. + +If defined in a virtual server section then the global value is overridden. + + B<execute = ">I<configuration>B<"> Use this directive to start an instance of ldirectord for
@@ -611,6 +618,7 @@ $EMAILALERT $EMAILALERTFREQ $EMAILALERTSTATUS + $SMTP $CALLBACK $CFGNAME
@@ -1321,6 +1329,9 @@ &config_error($line, "unable to open monitorfile $monitorfile: $!"); } $vsrv{monitorfile} = $monitorfile; + } elsif ($rcmd =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, "invalid SMTP server address"); + $vsrv{smtp} = $1; } else { &config_error($line, "Unknown command \"$linedata\""); }
@@ -1432,6 +1443,10 @@ $EMAILALERTFREQ = $1; } elsif ($linedata =~ /^emailalertstatus\s*=\s*(.*)/) { $EMAILALERTSTATUS = &parse_emailalertstatus($line, $1); + } elsif ($linedata =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, + "invalid SMTP server address"); + $SMTP = $1; } else { if ($linedata =~ /^timeout\s*=\s*(.*)/) { &config_error($line,
@@ -3928,6 +3943,34 @@ $status = 1; } + use Net::SMTP; + use Sys::Hostname; + + my $smtp_server; + my $hostname = hostname; + + $smtp_server = defined $v->{smtp} ? $v->{smtp} : + $SMTP; + + my $smtp = Net::SMTP->new($smtp_server); + + if ($smtp) { + $smtp->mail("$ENV{USER}\@$hostname"); + $smtp->to($to_addr); + $smtp->data(); + $smtp->datasend("From: $ENV{USER}\@$hostname\n"); + $smtp->datasend("To: $to_addr\n"); + $smtp->datasend("Subject: $subject\n\n"); + $smtp->datasend("Log-Message: $subject\n" . + "Daemon-Status: " . + &daemon_status_str() . "\n"); + $smtp->dataend(); + $smtp->quit; + } else { + &ld_log("failed to send SMTP email message\n"); + $status = 1; + } + return($status); }
Simon Horman
maintainerQuoted 12 lines · Caleb Anthony
Hello all,
Attached is a patch to ldirectord (version 1.186-ha-2.1.4) that adds a new configuration directive "smtp". This directive allows ldirectord to send notification emails via an external SMTP server instead of using the built-in
Mail::Mailermethods. I wrote this patch because none of the methods inMail::Mailerwere convenient for use in our environment. However, we do run an enterprise wide SMTP relay for internal notifications, such as those generated by ldirectord. I would imagine many other organizations are in the same situation we are, and this would be a good addition to ldirectord.
Quoted 6 lines
Feel free to add/change/remove anything that doesn't seem right with the code.
Also, let me know if should post this to the Linux-HA development mailing list instead of here.
Thanks.
Hi Caleb,
I'm a little confused about how this is different to Using the "smtp" type for Mail::Mailer? Could you explain a little about why that wasn't useful for your set-up?
Thanks
Signature · 3 lines
Simon Horman VA Linux Systems Japan K.K. Satellite Lab in Sydney, Australia H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
From what I understand about Mail::Mailer (maybe incorrectly!), in order to use the SMTP functionality, you have to be running an SMTP server on the same server as ldirectord. That isn't an option in our organization, so I had to add the ability to use an external SMTP server.
Am I wrong about Mail::Mailer? Can it use an SMTP server other than one on the server that ldirectord is also running on?
Thanks.
Quoted 34 lines · Simon Horman
Quoted 12 lines · Caleb Anthony
Hello all,
Attached is a patch to ldirectord (version 1.186-ha-2.1.4) that adds a new configuration directive "smtp". This directive allows ldirectord to send notification emails via an external SMTP server instead of using the built-in
Mail::Mailermethods. I wrote this patch because none of the methods inMail::Mailerwere convenient for use in our environment. However, we do run an enterprise wide SMTP relay for internal notifications, such as those generated by ldirectord. I would imagine many other organizations are in the same situation we are, and this would be a good addition to ldirectord.Quoted 6 lines
Feel free to add/change/remove anything that doesn't seem right with the code.
Also, let me know if should post this to the Linux-HA development mailing list instead of here.
Thanks.
Hi Caleb,
I'm a little confused about how this is different to Using the "smtp" type for
Mail::Mailer? Could you explain a little about why that wasn't useful for your set-up?Thanks
--
Simon Horman
VA Linux Systems Japan K.K. Satellite Lab in Sydney, Australia
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
Simon Horman
maintainerQuoted 8 lines · Caleb Anthony
Quoted 1 line
From what I understand about
Mail::Mailer(maybe incorrectly!), inorder to use the SMTP functionality, you have to be running an SMTP server on the same server as ldirectord. That isn't an option in our organization, so I had to add the ability to use an external SMTP server.
Am I wrong about
Mail::Mailer? Can it use an SMTP server other than one on the server that ldirectord is also running on?
Sorry, I was a bit confused.
I think that Mail::Mailer can probably do what you are after, but the current ldirectord code uses Mail::Send, which does not apper to be able to access an SMTP server.
With regards to the patch, I think that it might be nice to arrance things such that there are two functions,
one whcih contains the existing Mail::Send code, including the call to "use Mail::Send;". One that includes your new code, including any calls to use or require. And have ld_emailalert_send() call one of these functions depending on if $SMTP is set or not.
Signature · 3 lines
Simon Horman VA Linux Systems Japan K.K. Satellite Lab in Sydney, Australia H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
I think that's a good idea, I'll see what I can do to get a patch that adds that functionality.
Quoted 29 lines · Simon Horman
Quoted 8 lines · Caleb Anthony
Quoted 1 line
From what I understand about
Mail::Mailer(maybe incorrectly!), inorder to use the SMTP functionality, you have to be running an SMTP server on the same server as ldirectord. That isn't an option in our organization, so I had to add the ability to use an external SMTP server.
Am I wrong about
Mail::Mailer? Can it use an SMTP server other than one on the server that ldirectord is also running on?Sorry, I was a bit confused.
I think that
Mail::Mailercan probably do what you are after, but the current ldirectord code usesMail::Send, which does not apper to be able to access an SMTP server.With regards to the patch, I think that it might be nice to arrance things such that there are two functions,
one whcih contains the existingMail::Sendcode, including the call to "useMail::Send;". One that includes your new code, including any calls to use or require. And haveld_emailalert_send()call one of these functions depending on if $SMTP is set or not.--
Simon Horman
VA Linux Systems Japan K.K. Satellite Lab in Sydney, Australia
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
Simon Horman
maintainerQuoted 2 lines · Caleb Anthony
I think that's a good idea, I'll see what I can do to get a patch that adds that functionality.
Great, thanks.
Signature · 3 lines
Simon Horman VA Linux Systems Japan K.K. Satellite Lab in Sydney, Australia H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
Attached is a new patch. This one adds two new subs:ld_emailalert_net_smtp and ld_emailalert_mail_send. If an SMTP server is set in ldirectord.cf, then ld_emailalert_net_smtp will be called and the email will be sent via SMTP. If an SMTP server is not set in ldirectord.cf then ld_emailalert_mail_send will be called and the email will be sent via the Mail::Send methods.
Let me know what you think.
Caleb
Quoted 4 lines · Simon Horman
Quoted 2 lines · Caleb Anthony
I think that's a good idea, I'll see what I can do to get a patch that adds that functionality.
Quoted 8 lines
Great, thanks.
--
Simon Horman
VA Linux Systems Japan K.K. Satellite Lab in Sydney, Australia
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
tmp/ldirectord.smtp/ldirectord renamed from tmp/ldirectord.orig/ldirectord +82 -3
@@ -229,6 +229,13 @@ Default: all +B<smtp = >I<ip_address|hostname>B<"> + +A valid SMTP server address to use for sending email via SMTP. + +If defined in a virtual server section then the global value is overridden. + + B<execute = ">I<configuration>B<"> Use this directive to start an instance of ldirectord for
@@ -611,6 +618,7 @@ $EMAILALERT $EMAILALERTFREQ $EMAILALERTSTATUS + $SMTP $CALLBACK $CFGNAME
@@ -1321,6 +1329,9 @@ &config_error($line, "unable to open monitorfile $monitorfile: $!"); } $vsrv{monitorfile} = $monitorfile; + } elsif ($rcmd =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, "invalid SMTP server address"); + $vsrv{smtp} = $1; } else { &config_error($line, "Unknown command \"$linedata\""); }
@@ -1432,6 +1443,10 @@ $EMAILALERTFREQ = $1; } elsif ($linedata =~ /^emailalertstatus\s*=\s*(.*)/) { $EMAILALERTSTATUS = &parse_emailalertstatus($line, $1); + } elsif ($linedata =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, + "invalid SMTP server address"); + $SMTP = $1; } else { if ($linedata =~ /^timeout\s*=\s*(.*)/) { &config_error($line,
@@ -3880,14 +3895,13 @@ sub ld_emailalert_send { my ($subject, $v, $rserver, $currenttime) = (@_); - my $emailmsg; - my $emailfh; my $status = 0; my $to_addr; my $frequency; my $virtual_str; my $id; my $statusfilter; + my $smtp_server; $frequency = defined $v->{emailalertfreq} ? $v->{emailalert} : $EMAILALERTFREQ;
@@ -3914,6 +3928,72 @@ return 0; } + $smtp_server = defined $v->{smtp} ? $v->{smtp} : + $SMTP; + + if (defined $smtp_server) { + $status = &ld_emailalert_net_smtp($smtp_server, $to_addr, $subject); + } + else { + $status = &ld_emailalert_mail_send($to_addr, $subject); + } + + return($status); +} + +# ld_emailalert_net_smtp +# Send email alerts via SMTP server +# pre: smtp: SMTP server defined +# post: message is emailed if SMTP server is valid and working +# return: 0 on success +# 1 on error + +sub ld_emailalert_net_smtp +{ + my ($smtp_server, $to_addr, $subject) = (@_); + my $status = 0; + + use Net::SMTP; + use Sys::Hostname; + + my $hostname = hostname; + + my $smtp = Net::SMTP->new($smtp_server); + + if ($smtp) { + $smtp->mail("$ENV{USER}\@$hostname"); + $smtp->to($to_addr); + $smtp->data(); + $smtp->datasend("From: $ENV{USER}\@$hostname\n"); + $smtp->datasend("To: $to_addr\n"); + $smtp->datasend("Subject: $subject\n\n"); + $smtp->datasend("Log-Message: $subject\n" . + "Daemon-Status: " . + &daemon_status_str() . "\n"); + $smtp->dataend(); + $smtp->quit; + } else { + &ld_log("failed to send SMTP email message\n"); + $status = 1; + } + + return($status); +} + +# ld_emailalert_mail_send +# Send email alerts via Mail::Send +# pre: smtp: SMTP server not defined +# post: message is emailed if one of the Mail::Send methods works +# return: 0 on success +# 1 on error + +sub ld_emailalert_mail_send +{ + my ($to_addr, $subject) = (@_); + my $emailmsg; + my $emailfh; + my $status = 0; + use Mail::Send; &ld_log("emailalert: $subject");
@@ -3931,7 +4011,6 @@ return($status); } - # ld_emailalert_resend # Resend email alerts as neccessary # pre: none
Simon Horman
maintainerQuoted 8 lines · Caleb Anthony
Attached is a new patch. This one adds two new subs:
ld_emailalert_net_smtpandld_emailalert_mail_send. If an SMTP server is set in ldirectord.cf, thenld_emailalert_net_smtpwill be called and the email will be sent via SMTP. If an SMTP server is not set in ldirectord.cf thenld_emailalert_mail_sendwill be called and the email will be sent via theMail::Sendmethods.Let me know what you think.
Hi Caleb,
That looks pretty good to me. How well tested is it?
I have rediffed it against the current http://hg.linux-ha.org/dev tree. The result is below:
ldirectord/ldirectord.in +82 -2
@@ -248,6 +248,13 @@ If defined in a virtual server section t Default: all +B<smtp = >I<ip_address|hostname>B<"> + +A valid SMTP server address to use for sending email via SMTP. + +If defined in a virtual server section then the global value is overridden. + + B<execute = ">I<configuration>B<"> Use this directive to start an instance of ldirectord for
@@ -662,6 +669,7 @@ use vars qw( $EMAILALERT $EMAILALERTFREQ $EMAILALERTSTATUS + $SMTP $CLEANSTOP $CALLBACK
@@ -1422,6 +1430,9 @@ sub read_config ($1 eq "yes" || $1 eq "no") or &config_error($line, "cleanstop must be 'yes' or 'no'"); $vsrv{cleanstop} = $1; + } elsif ($rcmd =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, "invalid SMTP server address"); + $vsrv{smtp} = $1; } else { &config_error($line, "Unknown command \"$linedata\""); }
@@ -1540,6 +1551,10 @@ sub read_config ($1 eq "yes" || $1 eq "no") or &config_error($line, "cleanstop must be 'yes' or 'no'"); $CLEANSTOP = $1; + } elsif ($linedata =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, + "invalid SMTP server address"); + $SMTP = $1; } else { if ($linedata =~ /^timeout\s*=\s*(.*)/) { &config_error($line,
@@ -4109,14 +4124,13 @@ sub daemon_status_str sub ld_emailalert_send { my ($subject, $v, $rserver, $currenttime) = (@_); - my $emailmsg; - my $emailfh; my $status = 0; my $to_addr; my $frequency; my $virtual_str; my $id; my $statusfilter; + my $smtp_server; $frequency = defined $v->{emailalertfreq} ? $v->{emailalert} : $EMAILALERTFREQ;
@@ -4143,6 +4157,72 @@ sub ld_emailalert_send return 0; } + $smtp_server = defined $v->{smtp} ? $v->{smtp} : + $SMTP; + + if (defined $smtp_server) { + $status = &ld_emailalert_net_smtp($smtp_server, $to_addr, $subject); + } + else { + $status = &ld_emailalert_mail_send($to_addr, $subject); + } + + return($status); +} + +# ld_emailalert_net_smtp +# Send email alerts via SMTP server +# pre: smtp: SMTP server defined +# post: message is emailed if SMTP server is valid and working +# return: 0 on success +# 1 on error + +sub ld_emailalert_net_smtp +{ + my ($smtp_server, $to_addr, $subject) = (@_); + my $status = 0; + + use Net::SMTP; + use Sys::Hostname; + + my $hostname = hostname; + + my $smtp = Net::SMTP->new($smtp_server); + + if ($smtp) { + $smtp->mail("$ENV{USER}\@$hostname"); + $smtp->to($to_addr); + $smtp->data(); + $smtp->datasend("From: $ENV{USER}\@$hostname\n"); + $smtp->datasend("To: $to_addr\n"); + $smtp->datasend("Subject: $subject\n\n"); + $smtp->datasend("Log-Message: $subject\n" . + "Daemon-Status: " . + &daemon_status_str() . "\n"); + $smtp->dataend(); + $smtp->quit; + } else { + &ld_log("failed to send SMTP email message\n"); + $status = 1; + } + + return($status); +} + +# ld_emailalert_mail_send +# Send email alerts via Mail::Send +# pre: smtp: SMTP server not defined +# post: message is emailed if one of the Mail::Send methods works +# return: 0 on success +# 1 on error + +sub ld_emailalert_mail_send +{ + my ($to_addr, $subject) = (@_); + my $emailmsg; + my $emailfh; + my $status = 0; + use Mail::Send; &ld_log("emailalert: $subject");
@@ -4160,7 +4240,6 @@ sub ld_emailalert_send return($status); }
It's fairly well tested. I tried to break it as much as I could - setting an unreachable SMTP server, setting an invalid SMTP server address, sending a ton of e-mails with the code by starting, stopping, adding and removing real servers, etc. I'm going to put it into production on a few IPVS directors I have here. I can report back in about a week if you would like.
Also, there needs to be one addition to the ld_emailalert_net_smtp sub. The ld_emailalert_mail_send sub logs a message in ldirectord.log once an email is sent: &ld_log("emailalert: $subject");. I meant to include that same line in ld_emailalert_net_smtp so that each sub would be as similar as possible.
Could you add that line to ld_emailalert_net_smtp before you commit?
Thanks.
Quoted 162 lines · Simon Horman
Quoted 8 lines · Caleb Anthony
Attached is a new patch. This one adds two new subs:
ld_emailalert_net_smtpandld_emailalert_mail_send. If an SMTP server is set in ldirectord.cf, thenld_emailalert_net_smtpwill be called and the email will be sent via SMTP. If an SMTP server is not set in ldirectord.cf thenld_emailalert_mail_sendwill be called and the email will be sent via theMail::Sendmethods.Let me know what you think.
Hi Caleb,
That looks pretty good to me. How well tested is it?
I have rediffed it against the current http://hg.linux-ha.org/dev tree. The result is below:
Index: dev/ldirectord/ldirectord.in
===================================================================ldirectord/ldirectord.in 2009-05-08 10:27:02.000000000 +1000 renamed from ldirectord/ldirectord.in 2009-05-08 10:21:45.000000000 +1000 +0
-0@@ -248,6 +248,13 @@ If defined in a virtual server section tDefault: all
ldirectord/ldirectord.in 2009-05-08 10:27:02.000000000 +1000 renamed from ldirectord/ldirectord.in 2009-05-08 10:21:45.000000000 +1000 +7
-0+B<smtp = >I<ip_address|hostname>B<"> + +A valid SMTP server address to use for sending email via SMTP. + +If defined in a virtual server section then the global value is overridden. + +B<execute = ">I<configuration>B<">
Use this directive to start an instance of ldirectord for
ldirectord/ldirectord.in 2009-05-08 10:27:02.000000000 +1000 renamed from ldirectord/ldirectord.in 2009-05-08 10:21:45.000000000 +1000 +0
-0@@ -662,6 +669,7 @@ use vars qw($EMAILALERT
$EMAILALERTFREQ
$EMAILALERTSTATUS
+ $SMTP
$CLEANSTOP$CALLBACK
ldirectord/ldirectord.in 2009-05-08 10:27:02.000000000 +1000 renamed from ldirectord/ldirectord.in 2009-05-08 10:21:45.000000000 +1000 +7
-0@@ -1422,6 +1430,9 @@ sub read_config ($1 eq "yes" || $1 eq "no") or &config_error($line, "cleanstop must be 'yes' or 'no'"); $vsrv{cleanstop} = $1; + } elsif ($rcmd =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, "invalid SMTP server address"); + $vsrv{smtp} = $1; } else { &config_error($line, "Unknown command \"$linedata\""); }@@ -1540,6 +1551,10 @@ sub read_config ($1 eq "yes" || $1 eq "no") or &config_error($line, "cleanstop must be 'yes' or 'no'"); $CLEANSTOP = $1; + } elsif ($linedata =~ /^smtp\s*=\s*(.*)/) { + $1 =~ /(^([0-9A-Za-z._+-]+))/ or &config_error($line, + "invalid SMTP server address"); + $SMTP = $1; } else { if ($linedata =~ /^timeout\s*=\s*(.*)/) { &config_error($line,@@ -4109,14 +4124,13 @@ sub daemon_status_strsub
ld_emailalert_send
{
my ($subject, $v, $rserver, $currenttime) = (@_);
- my $emailmsg;
- my $emailfh;
my $status = 0;
my $to_addr;
my $frequency;
my $virtual_str;
my $id;
my $statusfilter;
+ my $smtp_server;$frequency = defined $v->{emailalertfreq} ? $v->{emailalert} :
$EMAILALERTFREQ;ldirectord/ldirectord.in 2009-05-08 10:27:02.000000000 +1000 renamed from ldirectord/ldirectord.in 2009-05-08 10:21:45.000000000 +1000 +66
-1@@ -4143,6 +4157,72 @@ sub ld_emailalert_send return 0; } + $smtp_server = defined $v->{smtp} ? $v->{smtp} : + $SMTP; + + if (defined $smtp_server) { + $status = &ld_emailalert_net_smtp($smtp_server, $to_addr, $subject); + } + else { + $status = &ld_emailalert_mail_send($to_addr, $subject); + } + + return($status); +} + +# ld_emailalert_net_smtp +# Send email alerts via SMTP server +# pre: smtp: SMTP server defined +# post: message is emailed if SMTP server is valid and working +# return: 0 on success +# 1 on error + +sub ld_emailalert_net_smtp +{ + my ($smtp_server, $to_addr, $subject) = (@_); + my $status = 0; + + use Net::SMTP; + use Sys::Hostname; + + my $hostname = hostname; + + my $smtp = Net::SMTP->new($smtp_server); + + if ($smtp) { + $smtp->mail("$ENV{USER}\@$hostname"); + $smtp->to($to_addr); + $smtp->data(); + $smtp->datasend("From: $ENV{USER}\@$hostname\n"); + $smtp->datasend("To: $to_addr\n"); + $smtp->datasend("Subject: $subject\n\n"); + $smtp->datasend("Log-Message: $subject\n" . + "Daemon-Status: " . + &daemon_status_str() . "\n"); + $smtp->dataend(); + $smtp->quit; + } else { + &ld_log("failed to send SMTP email message\n"); + $status = 1; + } + + return($status); +} + +# ld_emailalert_mail_send +# Send email alerts via Mail::Send +# pre: smtp: SMTP server not defined +# post: message is emailed if one of the Mail::Send methods works +# return: 0 on success +# 1 on error + +sub ld_emailalert_mail_send +{ + my ($to_addr, $subject) = (@_); + my $emailmsg; + my $emailfh; + my $status = 0; + use Mail::Send; &ld_log("emailalert: $subject");@@ -4160,7 +4240,6 @@ sub ld_emailalert_send return($status); } - # ld_emailalert_resend # Resend email alerts as neccessary # pre: none
Simon Horman
maintainerQuoted 7 lines · Caleb Anthony
It's fairly well tested. I tried to break it as much as I could - setting an unreachable SMTP server, setting an invalid SMTP server address, sending a ton of e-mails with the code by starting, stopping, adding and removing real servers, etc. I'm going to put it into production on a few IPVS directors I have here. I can report back in about a week if you would like.
Quoted 7 lines
Also, there needs to be one addition to the
ld_emailalert_net_smtpsub. Theld_emailalert_mail_sendsub logs a message in ldirectord.log once an email is sent: &ld_log("emailalert: $subject");. I meant to include that same line inld_emailalert_net_smtpso that each sub would be as similar as possible.Could you add that line to
ld_emailalert_net_smtpbefore you commit?
Sure, will do. Though I'll hold off on the commit until after I get some sleep.
Simon Horman
maintainerQuoted 8 lines · Simon Horman
Quoted 7 lines · Caleb Anthony
It's fairly well tested. I tried to break it as much as I could - setting an unreachable SMTP server, setting an invalid SMTP server address, sending a ton of e-mails with the code by starting, stopping, adding and removing real servers, etc. I'm going to put it into production on a few IPVS directors I have here. I can report back in about a week if you would like.
Quoted 7 lines
Quoted 7 lines
Also, there needs to be one addition to the
ld_emailalert_net_smtpsub. Theld_emailalert_mail_sendsub logs a message in ldirectord.log once an email is sent: &ld_log("emailalert: $subject");. I meant to include that same line inld_emailalert_net_smtpso that each sub would be as similar as possible.Could you add that line to
ld_emailalert_net_smtpbefore you commit?
I have moved the &ld_log() call to the parent function applied the change.
http://hg.linux-ha.org/dev/rev/fdd0e04fb520
If any further changes/fixes are needed please make them as an additional patch.
Thanks