From d60e0e93607a86a26950b593671d2909d1e32c4e Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 7 Dec 2009 13:20:24 +0000 Subject: [PATCH] 2009-12-07 Sancho Lerena * plugins/inventory: Fixed some problems with the plugin (for * linux). Added inventory for RPM systems. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2166 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/unix/ChangeLog | 5 ++++ pandora_agents/unix/plugins/inventory | 34 ++++++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index aa14fcd4f0..448bc9e4af 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,8 @@ +2009-12-07 Sancho Lerena + + * plugins/inventory: Fixed some problems with the plugin (for linux). Added + inventory for RPM systems. + 2009-12-03 Ramon Novoa * pandora_agent: Empty modules and plugins before loading a remote diff --git a/pandora_agents/unix/plugins/inventory b/pandora_agents/unix/plugins/inventory index 56d64e26b8..f524298707 100755 --- a/pandora_agents/unix/plugins/inventory +++ b/pandora_agents/unix/plugins/inventory @@ -135,19 +135,27 @@ sub get_software_module_data ($$) { my ($name, $modules) = @_; # Guess the current distribution - open (RELEASE_FILE, '< /etc/lsb-release') or return; - my $distrib_id = ; - last unless ($distrib_id =~ m/DISTRIB_ID\s*=\s*(\S+)/); - $distrib_id = $1; + my $distrib_id = ""; + + if ( -e "/etc/SuSE-release"){ + $distrib_id = "SUSE"; + } else { + open (RELEASE_FILE, '< /etc/lsb-release') or return; + $distrib_id = ; + last unless ($distrib_id =~ m/DISTRIB_ID\s*=\s*(\S+)/); + $distrib_id = $1; + } # List installed programs my @soft; if ($distrib_id eq 'Ubuntu') { @soft = `dpkg -l | grep ii`; } else { - return; + + @soft = `rpm -q -a --qf "ii\t%{NAME}\t%{VERSION}\t%{SUMMARY}\n"`; } + # Parse data foreach my $row (@soft) { next unless ($row =~ /^ii\s+(\S+)\s+(\S+)\s+([^\n]+)/); @@ -157,7 +165,6 @@ sub get_software_module_data ($$) { $module{'version'} = $2; $module{'description'} = $3; $module{'_keys'} = ['program', 'version','description']; - push (@{$modules->{$name}}, \%module); } } @@ -191,9 +198,18 @@ if ($#ARGV < 0) { # Parse command line parameters my %enabled; -my $enable_all = ($#ARGV > 0 ? 0 : 1); -my $interval = shift (@ARGV); -foreach my $module (@ARGV) { +my $interval = 1; +my $enable_all = 0; + +$interval = $ARGV[0]; +if ($#ARGV == 0){ + $enable_all = 1; +} + +foreach my $module (@ARGV) { + if ($module eq "all"){ + $enable_all = 1; + } $enabled{$module} = 1; }