Set the right OS and version for self-monitoring.

This commit is contained in:
Ramon Novoa 2016-07-21 11:47:37 +02:00
parent 53353651c9
commit 42454cd3e2
2 changed files with 17 additions and 3 deletions

View File

@ -4394,7 +4394,7 @@ sub pandora_self_monitoring ($$) {
my $xml_output = "";
$xml_output = "<agent_data os_name='Linux' os_version='".$pa_config->{'version'}."' agent_name='".$pa_config->{'servername'}."' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
$xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='Pandora FMS Server version " . $pa_config->{'version'} . "' agent_name='".$pa_config->{'servername'}."' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
$xml_output .=" <module>";
$xml_output .=" <name>Status</name>";
$xml_output .=" <type>generic_proc</type>";

View File

@ -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