2011-05-03 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/DB.pm, lib/PandoraFMS/DataServer.pm: Check that a group
	  exists before auto-creating an agent.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4297 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2011-05-03 14:24:51 +00:00
parent 7cee88e20b
commit ff9b6ecb14
3 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2011-05-03 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DB.pm, lib/PandoraFMS/DataServer.pm: Check that a group
exists before auto-creating an agent.
2011-04-29 Miguel de Dios <miguel.dedios@artica.es>
* util/pandora_xml_stress.pl: added the generate scatter and curve data

View File

@ -152,7 +152,7 @@ sub get_server_id ($$$) {
sub get_group_id ($$) {
my ($dbh, $group_name) = @_;
my $rc = get_db_value ($dbh, "SELECT id_grupo FROM tgrupo WHERE nombre = ?", safe_input($group_name));
my $rc = get_db_value ($dbh, 'SELECT id_grupo FROM tgrupo WHERE ' . db_text ('nombre') . ' = ?', safe_input($group_name));
return defined ($rc) ? $rc : -1;
}

View File

@ -314,9 +314,17 @@ sub process_xml_data ($$$$$) {
# Get OS, group and description
my $os = pandora_get_os ($data->{'os_name'});
my $group_id = undef;
$group_id = get_db_value ($dbh, 'SELECT id_grupo FROM tgrupo WHERE ' . db_text ('nombre') . ' = ?', $data->{'group'}) if (defined ($data->{'group'}));
$group_id = $pa_config->{'autocreate_group'} unless defined ($group_id);
my $group_id = -1;
$group_id = get_group_id ($dbh, $data->{'group'}) if (defined ($data->{'group'}));
if ($group_id == -1) {
$group_id = $pa_config->{'autocreate_group'};
if (! defined (get_group_name ($dbh, $group_id))) {
logger($pa_config, "Group id $group_id does not exist (check autocreate_group config token)", 3);
$AgentSem->up ();
return;
}
}
my $description = '';
$description = $data->{'description'} if (defined ($data->{'description'}));