[ZBX-5450] unit postfix cannot be used in the second parameter of count() function Created: 2012 Aug 14  Updated: 2017 May 30  Resolved: 2012 Aug 22

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 1.8.14, 2.0.2
Fix Version/s: 1.8.16rc1, 2.0.3rc1, 2.1.0

Type: Incident report Priority: Minor
Reporter: Kodai Terashima Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: triggers
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate

 Description   

Unit postfix (K, M,G, etc.) cannot be used in the second parameter of count() function.

The trigger expression

{hostname:itemkey.count(1m,930M,ge)}

>0 is set, the trigger become PROBLEM when item received bigger than 930. Following is zabbix_server.log output when item received value "950".

31451:20120814:174826.288 In evaluate_COUNT()
31451:20120814:174826.288 In get_function_parameter_uint() parameters:'1m,"930M","ge"' Nparam:1
31451:20120814:174826.288 In substitute_simple_macros() data:'1m'
31451:20120814:174826.288 get_function_parameter_uint() flag:0 value:60
31451:20120814:174826.288 End of get_function_parameter_uint():SUCCEED
31451:20120814:174826.288 In get_function_parameter_str() parameters:'1m,"930M","ge"' Nparam:2
31451:20120814:174826.288 In substitute_simple_macros() data:'930M'
31451:20120814:174826.288 get_function_parameter_str() value:'930M'
31451:20120814:174826.288 End of get_function_parameter_str():SUCCEED
31451:20120814:174826.288 In get_function_parameter_str() parameters:'1m,"930M","ge"' Nparam:3
31451:20120814:174826.288 In substitute_simple_macros() data:'ge'
31451:20120814:174826.288 get_function_parameter_str() value:'ge'
31451:20120814:174826.288 End of get_function_parameter_str():SUCCEED
31451:20120814:174826.288 In DBget_history()
31451:20120814:174826.288 query [txnlev:1] [select value from history_uint where itemid=22164 and clock>1344934045 and clock<=1344934105]
31451:20120814:174826.289 End of DBget_history()
31451:20120814:174826.289 In DBfree_history()
31451:20120814:174826.289 End of DBfree_history()
31451:20120814:174826.289 evaluate_COUNT() value:1



 Comments   
Comment by Kodai Terashima [ 2012 Aug 14 ]

line 490 in src/libs/zbxserver/evalfunc.c (In evaluate_COUNT):

if (2 <= nparams && FAIL == get_function_parameter_str(item->hostid, parameters, 2, &arg2))
goto exit;

It seems that this part should use get_function_parameter_uint() when second parameter is numeric value (numeric_search is 1).

<Sasha> The second parameter supports string for non-numeric items. We can't use the function get_function_parameter_uint() here.

<Kodai> I am not really sure this is good solution or not, but my first idea is like below:

if (2 <= nparams) {
if (numeric_search)

{ get_function_parameter_uint() ... }

else

{ get_function_parameter_str() ... }

}

In this case, string in the second parameter can be used for only log/text item, and number for only uint/float item. But it seems reasonable for me.

Comment by Alexander Vladishev [ 2012 Aug 22 ]

Fixed in the development branch svn://svn.zabbix.com/branches/dev/ZBX-5450.

Comment by dimir [ 2012 Aug 24 ]

Successfully tested. Please review my small change in r29836.

<Sasha> Thanks!

Comment by Alexander Vladishev [ 2012 Aug 25 ]

Fixed in pre-1.8.16 r29839, pre-2.0.3 29840 and pre-2.1.0 (trunk) 29841.

Generated at Thu Apr 25 18:28:21 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.