[pve-devel] [PATCH ha-manager 2/5] Env: add sendmail
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Apr 11 17:06:00 CEST 2016
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Env.pm | 6 ++++++
src/PVE/HA/Env/PVE2.pm | 9 +++++++++
src/PVE/HA/Sim/Env.pm | 7 +++++++
3 files changed, 22 insertions(+)
diff --git a/src/PVE/HA/Env.pm b/src/PVE/HA/Env.pm
index c7537b1..55f6684 100644
--- a/src/PVE/HA/Env.pm
+++ b/src/PVE/HA/Env.pm
@@ -132,6 +132,12 @@ sub log {
return $self->{plug}->log($level, @args);
}
+sub sendmail {
+ my ($self, $subject, $text) = @_;
+
+ return $self->{plug}->sendmail($subject, $text);
+}
+
# acquire a cluster wide manager lock
sub get_ha_manager_lock {
my ($self) = @_;
diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm
index 37823ee..ef6485d 100644
--- a/src/PVE/HA/Env/PVE2.pm
+++ b/src/PVE/HA/Env/PVE2.pm
@@ -226,6 +226,15 @@ sub log {
syslog($level, $msg);
}
+sub sendmail {
+ my ($self, $subject, $text) = @_;
+
+ my $mailfrom = 'root@' . $self->nodename();
+ my $mailto = 'root at localhost';
+
+ PVE::Tools::sendmail($mailto, $subject, $text, undef, $mailfrom);
+}
+
my $last_lock_status = {};
sub get_pve_lock {
diff --git a/src/PVE/HA/Sim/Env.pm b/src/PVE/HA/Sim/Env.pm
index 3715eff..4bb747a 100644
--- a/src/PVE/HA/Sim/Env.pm
+++ b/src/PVE/HA/Sim/Env.pm
@@ -224,6 +224,13 @@ sub log {
printf("%-5s %5d %12s: $msg\n", $level, $time, "$self->{nodename}/$self->{log_id}");
}
+sub sendmail {
+ my ($self, $subject, $text) = @_;
+
+ # only log subject, not spam the regression logs
+ $self->log('email', $subject);
+}
+
sub get_time {
my ($self) = @_;
--
2.1.4
More information about the pve-devel
mailing list