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.
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.
Comment