Hi, forum!
I see, in autodiscovery, the add_discovered_host() don't put the hostname in the hosts's record.
A simple solution:
operations.c: add_discovered_host
---------------------------------
char *host;
zabbix_log(LOG_LEVEL_WARNING, "In add_discovered_host(dhostid:" ZBX_FS_UI64 ")", dhostid);
result = DBselect("select h.ip, s.value from dservices s, dhosts h where s.key_ = 'system.hostname' and s.dhostid = h.dhostid and h.dhostid=" ZBX_FS_UI64, dhostid);
row = DBfetch(result);
if(row && DBis_null(row[0]) != SUCCEED)
{
ip=row[0];
host=row[1];
result2 = DBselect("select hostid from hosts where ip='%s' and " ZBX_COND_NODEID, ip, LOCAL_NODE("hostid"));
row2 = DBfetch(result2);
if(!row2 || DBis_null(row2[0]) == SUCCEED)
{
hostid = DBget_maxid("hosts","hostid");
DBexecute("insert into hosts (hostid,host,useip,ip) values (" ZBX_FS_UI64 ",'%s',1,'%s')", hostid, host, ip);
}
The trick is include in the discovery:
---------------------------------------
Checks: [ ] ZABBIX agent (10050) "system.hostname"
[ ] ZABBIX agent (10050) "system.uname"
This, put in the dservices, hostname of the machine.
The uname is for check for constant "Linux" in the uname string.
I don't test this on windows, but, I suppouse this can't work.
Please, tell me about if you have another solution.
TIA
jorge infante
I see, in autodiscovery, the add_discovered_host() don't put the hostname in the hosts's record.
A simple solution:
operations.c: add_discovered_host
---------------------------------
char *host;
zabbix_log(LOG_LEVEL_WARNING, "In add_discovered_host(dhostid:" ZBX_FS_UI64 ")", dhostid);
result = DBselect("select h.ip, s.value from dservices s, dhosts h where s.key_ = 'system.hostname' and s.dhostid = h.dhostid and h.dhostid=" ZBX_FS_UI64, dhostid);
row = DBfetch(result);
if(row && DBis_null(row[0]) != SUCCEED)
{
ip=row[0];
host=row[1];
result2 = DBselect("select hostid from hosts where ip='%s' and " ZBX_COND_NODEID, ip, LOCAL_NODE("hostid"));
row2 = DBfetch(result2);
if(!row2 || DBis_null(row2[0]) == SUCCEED)
{
hostid = DBget_maxid("hosts","hostid");
DBexecute("insert into hosts (hostid,host,useip,ip) values (" ZBX_FS_UI64 ",'%s',1,'%s')", hostid, host, ip);
}
The trick is include in the discovery:
---------------------------------------
Checks: [ ] ZABBIX agent (10050) "system.hostname"
[ ] ZABBIX agent (10050) "system.uname"
This, put in the dservices, hostname of the machine.
The uname is for check for constant "Linux" in the uname string.
I don't test this on windows, but, I suppouse this can't work.
Please, tell me about if you have another solution.
TIA
jorge infante