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);