[ZBX-11481] In some cases the server or proxy does not resolve macros in host interfaces Created: 2016 Nov 14 Updated: 2017 Jun 25 Resolved: 2017 Feb 04 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Proxy (P), Server (S) |
Affects Version/s: | 2.2.15, 3.0.5, 3.2.1, 3.4.0alpha1 |
Fix Version/s: | 2.2.17rc1, 3.0.8rc1, 3.2.4rc1, 3.4.0alpha1 |
Type: | Incident report | Priority: | Critical |
Reporter: | Alexander Vladishev | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | cache, macros | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
Configuration: host name: 127.0.0.1 host visible name: dns Zabbix agent main interface: IP: {HOST.HOST} DNS: {HOST.NAME} 1st case: Action message: {ITEM.NAME} : {ITEM.KEY} Item name: item {$M} $1 $2 $3 $4 $5 $6 $7 Item key: item[{$M}, {HOST.CONN}, {HOST.IP}, {HOST.DNS}, {HOST.HOST}, {HOSTNAME}, {HOST.NAME}] Generated message: item host-macro host-macro {HOST.HOST} {HOST.HOST} {HOST.NAME} 127.0.0.1 127.0.0.1 dns : item[host-macro, {HOST.HOST}, {HOST.HOST}, {HOST.NAME}, 127.0.0.1, 127.0.0.1, dns] Expected: item host-macro host-macro 127.0.0.1 127.0.0.1 dns 127.0.0.1 127.0.0.1 dns : item[host-macro, 127.0.0.1, 127.0.0.1, dns, 127.0.0.1, 127.0.0.1, dns] 2nd case Poller can't process items with such interface: Get value from agent failed: gethostbyname() failed for '{HOST.HOST}': [1] Unknown host |
Comments |
Comment by Sergejs Paskevics [ 2016 Nov 23 ] |
Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-11481 |
Comment by Andris Zeila [ 2016 Nov 23 ] |
(1) Interface related host macros (HOST_IP, HOST_CONN, HOST_DNS, HOST_PORT) are resolved by using default agent interface rather than the corresponding item interface. This seems to be an old bug, but it should be fixed before (together) with host interface macro resolving. DBget_item_value() function already contains a partial logic for proper interface macro resolving when processing item name/key macros, although it does not seem quite right. It should be fixed and expanded to support also host ip, dns, conn, port macros. The interface used to resolve the host macros must be chosen by following rules: s.paskevics Please check my changes in r64144. I think now it works correctly. RESOLVED wiper Since it was decided to use configuration cache rather than database it would be better to close this and open new subissues regarding new implementation. |
Comment by Andris Zeila [ 2016 Dec 02 ] |
(2) For 2.2 branch we should better keep the original processing for all non interface related macros. Practically that would mean to rewrite DBget_interface_value() funciton to use configuration cache instead of database. s.paskevics RESOLVED in r64575. wiper Coding style - in later branches internal configuration cache functions are prefixed with dc_ - dc_get_interface_by_type, dc_get_interface_by_itemid, dc_get_interface_by_type s.paskevics RESOLVED in r64653. wiper CLOSED |
Comment by Andris Zeila [ 2016 Dec 21 ] |
(3) DCsync_interfaces() will not remove deleted interfaces from cache. We should iterate the config->interfaces and check if the interface was updated like it was done before. s.paskevics RESOLVED in r64653. wiper CLOSED |
Comment by Andris Zeila [ 2016 Dec 23 ] |
(4) There are few issues with interface macro processing:
s.paskevics RESOLVED in r64803. wiper The first point was not fixed
REOPENED s.paskevics RESOLVED in r64881. wiper CLOSED |
Comment by Andris Zeila [ 2016 Dec 23 ] |
(5) In DCsync_interfaces() the existing interface check is done by iterating interfaces vector, which is not optimal. It would be better to store interface identifiers in uint64 vector, sort it and then use bsearch when checking for existing interfaces. s.paskevics RESOLVED in r64803. wiper This could be improved more. We are iterating interfaces hashset twice and both times checking if interface should be removed. The second check is redundant, as the deleted interfaces would be already removed. My suggestion would be to move macro resolving code in separate function and implement separate interaces hashset iterations for main agent and the rest of interface types. s.paskevics RESOLVED in r64881. wiper CLOSED |
Comment by Andris Zeila [ 2017 Jan 04 ] |
Successfully tested, please review changes in r64887 |
Comment by Sergejs Paskevics [ 2017 Jan 05 ] |
Fixed in:
|
Comment by Sergejs Paskevics [ 2017 Jan 24 ] |
(6) (CID 155642) Calling DCconfig_get_interface without checking return value: DCconfig_get_items_by_itemids(&dc_item, &itemid, &errcode, 1, ZBX_FLAG_ITEM_FIELDS_DEFAULT); if (INTERFACE_TYPE_UNKNOWN == dc_item.interface.type) DCconfig_get_interface(&dc_item.interface, dc_item.host.hostid, 0); REOPENED s.paskevics RESOLVED in development branch svn://svn.zabbix.com/branches/dev/ZBX-11481 wiper DCconfig_get_interface() is still called without checking it's return value. s.paskevics RESOLVED in r65314. wiper looks okay, please review minor code improvements in r65351. s.paskevics Looks good. CLOSED. glebs.ivanovskis Coverity is happy too, defect is eliminated. sasha I'm also happy. Thanks! |
Comment by Andris Zeila [ 2017 Jan 30 ] |
Successfully tested |
Comment by Sergejs Paskevics [ 2017 Jan 31 ] |
Fixed in:
|
Comment by richlv [ 2017 Feb 20 ] |
(7) nitpicking on the changelog entry : sasha Thanks! RESOLVED in r69504. CLOSED |