PDA

View Full Version : auto registration bug (1.1 beta 7)


kevinappel
06-03-2006, 23:14
I traced code for the auto-registration and here is what I found:
Inside the autoregister function, line 69 of autoregister.c, there is a check to see if the host is already in the database, if it is, then it will call the function to add it which fails because it is already there. I swapped the two lines of code and placed them in the else clause so if it doesnt find a match, then add the host:

if(zbx_regexp_match(server, pattern, &len) != 0)
{
zabbix_log( LOG_LEVEL_DEBUG, "Matched [%s] [%s]",server,pattern);
}
else
{
zabbix_log( LOG_LEVEL_DEBUG, "No match [%s] [%s]",server,pattern);
register_new_host(server, hostid);
break;
}

This now worked to pick up new hosts, however I ran into another problem. Inside the add host function, it will call DBadd_template_to_host function and the sql is below.

zabbix_log( LOG_LEVEL_DEBUG, "In DBadd_templates_to_host(%d,%d)", hostid, host_templateid);

snprintf(sql,sizeof(sql)-1,"select templateid,items,triggers,graphs from hosts_templates where hostid=%d", host_templateid);

I do not have any entries in the hosts_templates table, even though I have templates inside the hosts table.

I was going to change the sql query but figured the table was there for a reason.

SAT QPass
15-03-2006, 13:00
I cannot seem to even get Zabbix to auto assign a template at all currently. And I was able to reproduce your problem. Let me know if you find a way to not only register the host, but attach it to a template.

kevinappel
16-03-2006, 19:35
Ok, well i got a little bit further. I am made a template off of a template and I am using this template for my autoregistration. Since my problem appears to be with the hosts_templates table, I did a one line insert:
insert into hosts_templates (hostid,templateid,items,triggers,graphs) values ('10011','10001','7','7','1');

Where 10011 is the id of my new template, and 10001 is the id of the template the new template was created from. I just picked random numbers for the remaining values.
After doing this, I started at an agent and it picked up instantly and added with all the items the template had.

So now that I can get this to work, does anybody have a clue on the correct way to populate the hosts_templates table?

globifrosch
21-03-2006, 07:44
for me autoregistration is also not working.

i turned on full debug messages in zabbix_server.conf, but there are only manual registred host's showing up.

kevinappel
21-03-2006, 20:39
Did you try to make the change I posted and recompile the binaries for the server?

This was my biggest problem, then secondly that hosts_templates table

Alexei
22-03-2006, 08:08
The autoregistration is broken in 1.1beta7. Please give us some time to fix it.