2012-04-25 Sergio Martin <sergio.martin@artica.es>
* unix/plugins/inventory: Fixed several bugs in the inventory plugin as missed separator to end the parse, fill with empty string the empty columns, etc. for bug 3519796 Merged from 4.0.x git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6157 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
d633dc7737
commit
4666928be1
|
@ -1,3 +1,10 @@
|
||||||
|
2012-04-25 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* unix/plugins/inventory: Fixed several bugs in the
|
||||||
|
inventory plugin as missed separator to end the parse,
|
||||||
|
fill with empty string the empty columns, etc. for bug 3519796
|
||||||
|
Merged from 4.0.x
|
||||||
|
|
||||||
2012-04-25 Dario Rodriguez <dario.rodriguez@artica.es>
|
2012-04-25 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
* win32/bin/pandora_agent.conf: Fixed a default module type.
|
* win32/bin/pandora_agent.conf: Fixed a default module type.
|
||||||
|
|
|
@ -31,7 +31,12 @@ my $Separator;
|
||||||
sub get_module_data ($$$$) {
|
sub get_module_data ($$$$) {
|
||||||
my ($name, $hwinfo, $keys, $modules) = @_;
|
my ($name, $hwinfo, $keys, $modules) = @_;
|
||||||
my %module;
|
my %module;
|
||||||
|
|
||||||
|
# Store keys
|
||||||
|
foreach my $key (@{$keys}) {
|
||||||
|
push (@{$module{'_keys'}}, $key);
|
||||||
|
}
|
||||||
|
|
||||||
# Parse module data
|
# Parse module data
|
||||||
while (my $line = shift (@{$hwinfo})) {
|
while (my $line = shift (@{$hwinfo})) {
|
||||||
if ($line =~ /$Separator/) {
|
if ($line =~ /$Separator/) {
|
||||||
|
@ -41,7 +46,8 @@ sub get_module_data ($$$$) {
|
||||||
foreach my $key (@{$keys}) {
|
foreach my $key (@{$keys}) {
|
||||||
if ($line =~ /$key:\s+(.+)/) {
|
if ($line =~ /$key:\s+(.+)/) {
|
||||||
$module{$key} = $1;
|
$module{$key} = $1;
|
||||||
push (@{$module{'_keys'}}, $key);
|
# Replace semicolon by comma to avoid parse errors
|
||||||
|
$module{$key} =~ s/;/,/g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,6 +112,8 @@ sub get_processes ($$) {
|
||||||
my %module;
|
my %module;
|
||||||
# Remove carriage returns
|
# Remove carriage returns
|
||||||
$row =~ s/[\n\l\f]//g;
|
$row =~ s/[\n\l\f]//g;
|
||||||
|
# Replace semicolon by comma to avoid parse errors
|
||||||
|
$row =~ s/;/,/g;
|
||||||
$module{'service'} = $row;
|
$module{'service'} = $row;
|
||||||
$module{'_keys'} = ['service'];
|
$module{'_keys'} = ['service'];
|
||||||
push (@{$modules->{$name}}, \%module);
|
push (@{$modules->{$name}}, \%module);
|
||||||
|
@ -170,6 +178,10 @@ sub get_software_module_data ($$) {
|
||||||
$module{'program'} = $1;
|
$module{'program'} = $1;
|
||||||
$module{'version'} = $2;
|
$module{'version'} = $2;
|
||||||
$module{'description'} = $3;
|
$module{'description'} = $3;
|
||||||
|
# Replace semicolon by comma to avoid parse errors
|
||||||
|
$module{'program'} =~ s/;/,/g;
|
||||||
|
$module{'version'} =~ s/;/,/g;
|
||||||
|
$module{'description'} =~ s/;/,/g;
|
||||||
$module{'_keys'} = ['program', 'version','description'];
|
$module{'_keys'} = ['program', 'version','description'];
|
||||||
push (@{$modules->{$name}}, \%module);
|
push (@{$modules->{$name}}, \%module);
|
||||||
}
|
}
|
||||||
|
@ -184,10 +196,12 @@ sub print_module ($$) {
|
||||||
print " <datalist>\n";
|
print " <datalist>\n";
|
||||||
foreach my $item (@{$module}) {
|
foreach my $item (@{$module}) {
|
||||||
# Compose module data
|
# Compose module data
|
||||||
my $data = '';
|
my $data = undef;
|
||||||
foreach my $key (@{$item->{'_keys'}}) {
|
foreach my $key (@{$item->{'_keys'}}) {
|
||||||
next unless defined ($item->{$key});
|
$data = (!defined($data) ? '' : "$data;");
|
||||||
$data .= ($data eq '' ? '' : ';') . $item->{$key};
|
if (defined($item->{$key})) {
|
||||||
|
$data .= $item->{$key};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print " <data><![CDATA[$data]]></data>\n";
|
print " <data><![CDATA[$data]]></data>\n";
|
||||||
|
@ -232,7 +246,7 @@ close (FILE);
|
||||||
|
|
||||||
# Retrieve hardware information
|
# Retrieve hardware information
|
||||||
$Mode = 'LSHW';
|
$Mode = 'LSHW';
|
||||||
$Separator = '';
|
$Separator = '\s+\*\-';
|
||||||
my @hwinfo = `lshw 2>/dev/null`;
|
my @hwinfo = `lshw 2>/dev/null`;
|
||||||
if ($? != 0) {
|
if ($? != 0) {
|
||||||
$Mode = 'HWINFO';
|
$Mode = 'HWINFO';
|
||||||
|
|
Loading…
Reference in New Issue