[ZBX-9355] Insufficient log message: "cannot link template: template with item key ... already linked to the host" Created: 2015 Mar 02  Updated: 2017 May 30  Resolved: 2015 Jul 02

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 2.2.7
Fix Version/s: 2.2.10rc1, 2.4.5rc1, 2.5.0

Type: Incident report Priority: Trivial
Reporter: Filipp Sudanov (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: logging, usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-7774 network discovery can not link templa... Closed

 Description   

The following Zabbix server log message should give details about host name and template name:

31759:20150302:162834.884 cannot link template: template with item key "agent.hostname" already linked to the host


 Comments   
Comment by richlv [ 2015 Mar 03 ]

(1) please see subissue 1 in ZBX-7774 - it mentions a very similar message and suggests to log action name in that case, too

igorsh RESOLVED in r52585. CLOSED.

<richlv> hmm, looks like this was not reviewed... additionally, was all suggested data from that issue added to the log message ?

Comment by Igors Homjakovs (Inactive) [ 2015 Mar 06 ]

Fixed in svn://svn.zabbix.com/branches/dev/ZBX-9355

Comment by Andris Zeila [ 2015 Mar 09 ]

(2) Multiple issues in get_conflicting_template_names() function:

  1. Using zbx_snprintf_alloc() function to concatenate list of template names would be more efficient than using zbx_strdcatf() function. This would also make easier to simply truncate the resulting template name list by 2 characters (as the string size would be already known) instead of using zbx_rtrim() to remove trailing ', '.
  2. Instead of selecting hostid from hosts and using zbx_host_string() to retrieve host name (note that we can't use atoi() to convert unsigned 64 bit integer value hostid) it would be more efficient to directly select host field.
  3. There is no point in using DBselectN() as we are operating with limited data set.

igorsh RESOLVED in r52666.

wiper CLOSED

Comment by Andris Zeila [ 2015 Mar 09 ]

(3) It would be nice to know the list of templates in the case of any linking failure, not just duplicate keys. So my suggestion would be to convert get_conflicting_template_names() to get_template_names() function and use it to print involved templates in all DBcopy_template_elements() function validation warning messages. In this case printing also the list of templates with matching keys would be excessive.

igorsh RESOLVED in r52666.

wiper The idea was to print the list of involved template names in the top function writing the warning messages - DBcopy_template_elements(). In this way the templates will be printed for all linking failure messages, not just for conflicting item keys.

RESOLVED in r52699

igorsh Thank you. Looks good. CLOSED.

Comment by Igors Homjakovs (Inactive) [ 2015 Apr 08 ]

Available in 2.2.10rc1 r53002, 2.4.5rc1 r53003 and 2.5.0 (trunk) r53004.

Comment by richlv [ 2015 Apr 09 ]

(4) as ZBX-7774 was closed as a duplicate of this issue, it would be nice to clarify that, apparently, inability to link such templates by the server has been fixed ? if so, has it been reviewed and tested, just in case ?

wiper It was reviewed and tested, but would be nice to write something in changelog

igorsh It has been mentioned in the Changelog:

added host name and names of conflicting templates to the error message when templates fail to link due to a duplicate item, fixed linking of templates containing web scenarios

Please reopen if we need to add something else.

RESOLVED.

wiper CLOSED

Generated at Sat Apr 20 09:06:51 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.