From 42454cd3e2cf73092e3f8a1e21678f02fe0c85ec 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. --- 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 36a437d3e7..8c51b770b5 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4394,7 +4394,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 8b66c37ae9..d6b21674b8 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -60,6 +60,8 @@ our @EXPORT = qw( TRANSACTIONALSERVER METACONSOLE_LICENSE $DEVNULL + $OS + $OS_VERSION RECOVERED_ALERT FIRED_ALERT cron_get_closest_in_range @@ -122,8 +124,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