[pve-devel] [PATCH manager] pvestatd: report perl warns in log

Thomas Lamprecht t.lamprecht at proxmox.com
Tue May 24 14:31:56 CEST 2016


Reuse code from bin/pveproxy to show warnings in the syslog.

This is useful, for example, the user could configure a status
server wrongly but he wouldn't get any message that his config is
messed up, it would just fail silently.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 bin/pvestatd | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/bin/pvestatd b/bin/pvestatd
index 98033ad..5cd727e 100755
--- a/bin/pvestatd
+++ b/bin/pvestatd
@@ -5,8 +5,18 @@ use warnings;
 
 use PVE::INotify;
 use PVE::RPCEnvironment;
+use PVE::SafeSyslog;
 use PVE::Service::pvestatd;
 
+$SIG{'__WARN__'} = sub {
+    my $err = $@;
+    my $t = $_[0];
+    chomp $t;
+    print STDERR "$t\n";
+    syslog('warning', "%s", $t);
+    $@ = $err;
+};
+
 my $prepare = sub {
     my $rpcenv = PVE::RPCEnvironment->init('priv');
 
-- 
2.1.4





More information about the pve-devel mailing list