From b49fc5aa9bfed63733537a8195c3d24167f68b91 Mon Sep 17 00:00:00 2001 From: ramonn Date: Wed, 9 Jun 2010 12:24:15 +0000 Subject: [PATCH] 2010-06-09 Ramon Novoa * pandora_agent: Improved OS version detection. Disabled error output for plugins. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2898 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/unix/ChangeLog | 5 +++++ pandora_agents/unix/pandora_agent | 25 +++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index 6fc30630e5..6035115407 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,8 @@ +2010-06-09 Ramon Novoa + + * pandora_agent: Improved OS version detection. Disabled error output + for plugins. + 2010-06-09 Ramon Novoa * pandora_agent.spec: Create the man dir. diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index a9d14a2b30..ce7d38e903 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -580,17 +580,26 @@ sub md5 ($) { ################################################################################ sub guess_os_version ($) { my $os = shift; + my $os_version; # Linux - return `lsb_release -sd` if ($os eq 'linux'); - + if ($os eq 'linux') { + $os_version = `lsb_release -sd 2>/dev/null`; # AIX - if ($os eq 'aix') { - return "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); - } - + } elsif ($os eq 'aix') { + $os_version = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); # Solaris, HP-UX, BSD and others - return `uname -r`; + } else { + $os_version = `uname -r`; + } + + # Something went wrong + return '' unless defined ($os_version); + + # Remove any trailing new lines + chomp ($os_version); + + return $os_version; } ################################################################################ @@ -948,7 +957,7 @@ while (1) { # Execute plugins foreach my $plugin (@Plugins) { - my $output = `$ConfDir/plugins/$plugin`; + my $output = `$ConfDir/plugins/$plugin 2>/dev/null`; # Do not save the output if there was an error next unless ($? eq 0);