From 3654009b8d0b62a75cc9303bc9a1a2b5a3cffeed Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 21 Jul 2016 11:47:37 +0200 Subject: [PATCH] Set the right OS and version for self-monitoring. (cherry picked from commit 42454cd3e2cf73092e3f8a1e21678f02fe0c85ec) --- pandora_server/lib/PandoraFMS/Core.pm | 2 +- pandora_server/lib/PandoraFMS/Tools.pm | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index f07894445b..ecac3c50b2 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4371,7 +4371,7 @@ sub pandora_self_monitoring ($$) { my $xml_output = ""; - $xml_output = ""; + $xml_output = ""; $xml_output .=" "; $xml_output .=" Status"; $xml_output .=" generic_proc"; diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 92f5f43d0f..c8610ee893 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -59,6 +59,8 @@ our @EXPORT = qw( SATELLITESERVER METACONSOLE_LICENSE $DEVNULL + $OS + $OS_VERSION RECOVERED_ALERT FIRED_ALERT STATUS_NORMAL @@ -132,8 +134,20 @@ use constant METACONSOLE_LICENSE => 0x01; use constant RECOVERED_ALERT => 0; use constant FIRED_ALERT => 1; -# /dev/null -our $DEVNULL = ($^O eq 'MSWin32') ? '/Nul' : '/dev/null'; +# Set OS, OS version and /dev/null +our $OS = $^O; +our $OS_VERSION; +our $DEVNULL = '/dev/null'; +if ($OS eq 'linux') { + $OS_VERSION = `lsb_release -sd 2>/dev/null`; +} elsif ($OS eq 'aix') { + $OS_VERSION = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); +} elsif ($OS =~ /win/i) { + $OS = "windows"; + $OS_VERSION = `ver`; + $DEVNULL = '/Nul'; +} +chomp($OS_VERSION); ######################################################################## ## SUB pandora_trash_ascii