[pve-devel] [RFC ha-manager] env: allow email logging

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Apr 8 09:59:11 CEST 2016


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

So, I'm torn between thinking that this may be an actual good idea
or just a rather dirty hack...
You could see emails as logging in the wider sense. Also, this is
surely the shortest patch allowing sending emails on failures like
fatal fence errors.

An alternative would be to add a new method to the env, like sendmail.
The points against this would be:
* its a new method, we want to keep Env as small as possible
* for Test/Sim Env it would do the same as log, so the above
  would be better for them

Thoughts?

 src/PVE/HA/Env/PVE2.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm
index 79fe522..04a4d80 100644
--- a/src/PVE/HA/Env/PVE2.pm
+++ b/src/PVE/HA/Env/PVE2.pm
@@ -223,7 +223,11 @@ sub log {
 
     chomp $msg;
 
-    syslog($level, $msg);
+    if ($level eq 'email') {
+	PVE::Tools::sendmail('root at localhost', 'PVE HA Manager', $msg);
+    } else {
+	syslog($level, $msg);
+    }
 }
 
 my $last_lock_status = {};
-- 
2.1.4





More information about the pve-devel mailing list