diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 80224be2c5..2d595d530d 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2013-04-17 Ramon Novoa + + * lib/PandoraFMS/WMIServer.pm: Style fix. + + * lib/PandoraFMS/Core.pm, + lib/PandoraFMS/DataServer.pm: Added support for multiple ip + addresses. + 2013-04-08 Hirofumi Kosaka * util/tentacle_serverd: Tiny improvement. Changed to use diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index df65910182..68e0330e33 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2434,11 +2434,9 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$) { ########################################################################## # Add an address if not exists and add this address to taddress_agent if not exists ########################################################################## -sub pandora_add_agent_address ($$$$) { - my ($pa_config, $agent_id, $addr, $dbh) = @_; - - my $agent_name = get_agent_name($dbh, $agent_id); - +sub pandora_add_agent_address ($$$$$) { + my ($pa_config, $agent_id, $agent_name, $addr, $dbh) = @_; + # Add the new address if it does not exist my $addr_id = get_addr_id ($dbh, $addr); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index fccbcd5562..d8939afc10 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -262,8 +262,21 @@ sub process_xml_data ($$$$$) { # Get agent address from the XML if available my $address = '' ; - $address = $data->{'address'} if (defined ($data->{'address'})); + my @address_list; + if (defined ($data->{'address'}) && $data->{'address'} ne '') { + @address_list = split (',', $data->{'address'}); + # Trim addresses + for (my $i = 0; $i <= $#address_list; $i++) { + $address_list[$i] =~ s/^\s+|\s+$//g ; + } + + # Save the first address as the main address + $address = $address_list[0]; + $address =~ s/^\s+|\s+$//g ; + shift (@address_list); +} + # Get agent id my $agent_id = get_agent_id ($dbh, $agent_name); if ($agent_id < 1) { @@ -294,6 +307,11 @@ sub process_xml_data ($$$$$) { return; } + # Add the main address to the address list + if ($address ne '') { + pandora_add_agent_address($pa_config, $agent_id, $agent_name, $address, $dbh); + } + # Process custom fields if(defined($data->{'custom_fields'})) { foreach my $custom_fields (@{$data->{'custom_fields'}}) { @@ -345,15 +363,16 @@ sub process_xml_data ($$$$$) { } # Learning mode else { - - # Update agent address if necessary + + # Update the main address if ($address ne '' && $address ne $agent->{'direccion'}) { - - # Update the main address pandora_update_agent_address ($pa_config, $agent_id, $agent_name, $address, $dbh); - - # Update the addres list if necessary - pandora_add_agent_address($pa_config, $agent_id, $address, $dbh); + pandora_add_agent_address($pa_config, $agent_id, $agent_name, $address, $dbh); + } + + # Update additional addresses + foreach my $address (@address_list) { + pandora_add_agent_address($pa_config, $agent_id, $agent_name, $address, $dbh); } # Update parent if is allowed and is valid diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index f8eb27eb03..5c13fc9dbb 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -53,7 +53,7 @@ sub new ($$;$) { return undef unless $config->{'wmiserver'} == 1; # Check for a WMI client - if (system ($config->{'wmi_client'} . ' > /dev/null 2>&1') != 256) { + if (system ($config->{'wmi_client'} . ' > /dev/null 2>&1') >> 8 != 1) { logger ($config, ' [E] ' . $config->{'wmi_client'} . " not found. Pandora FMS WMI Server needs a DCOM/WMI client.", 1); print_message ($config, ' [E] ' . $config->{'wmi_client'} . " not found. Pandora FMS WMI Server needs a DCOM/WMI client.", 1); return undef;