[ZBX-10658] weird behavior of function count(), numeric items, and empty patterns Created: 2016 Apr 13 Updated: 2017 May 30 Resolved: 2016 Apr 21 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 3.0.1 |
Fix Version/s: | 2.2.13rc1, 3.0.3rc1, 3.2.0alpha1 |
Type: | Incident report | Priority: | Minor |
Reporter: | Aleksandrs Saveljevs | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | functions | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
Let's look at evaluate_COUNT() and the following lines in particular: if (NULL != arg2 && '\0' == *arg2 && (0 != numeric_search || OP_LIKE == op)) zbx_free(arg2); ... for (i = 0; i < values.values_num; i++) { if (NULL == arg2 || ...) { count++; } } These lines mean that if we are doing a count() on numeric items and the second argument is empty, we will always count existing values. For instance, the following triggers will always fire, regardless of item value: {Zabbix server:numeric.count(#1,,eq)} <> 0 {Zabbix server:numeric.count(#1,,lt)} <> 0 |
Comments |
Comment by Glebs Ivanovskis (Inactive) [ 2016 Apr 19 ] |
Fix for version 2.2 is available in development branch svn://svn.zabbix.com/branches/dev/ZBX-10658 revision 59497. |
Comment by Aleksandrs Saveljevs [ 2016 Apr 20 ] |
(1) There is the following warning: evalfunc.c:575:73: warning: '&&' within '||' [-Wlogical-op-parentheses] if ((NULL != arg2 && '\0' != *arg2) || (NULL != arg3 && '\0' != *arg3) && OP_LIKE != op) ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ evalfunc.c:575:73: note: place parentheses around the '&&' expression to silence this warning if ((NULL != arg2 && '\0' != *arg2) || (NULL != arg3 && '\0' != *arg3) && OP_LIKE != op) ^ ( ) asaveljevs RESOLVED in r59564. glebs.ivanovskis Very cool optimization of the first condition! Well done! |
Comment by Glebs Ivanovskis (Inactive) [ 2016 Apr 20 ] |
Fixed in pre-2.2.13rc1 r59570, pre-3.0.3rc1 r59571, pre-3.1.0 (trunk) r59573. |