[ZBXNEXT-3434] add modulus and integer division operators Created: 2016 Sep 13 Updated: 2021 May 21 Resolved: 2021 May 21 |
|
Status: | Closed |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | API (A), Frontend (F), Server (S) |
Affects Version/s: | 3.2.0 |
Fix Version/s: | None |
Type: | Change Request | Priority: | Minor |
Reporter: | Aleksandrs Saveljevs | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 3 |
Labels: | newtriggeroperator | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
Zabbix currently supports a division operator /, which yields a floating-point value. It would be useful to have modulus (say, % or rem) and integer division (say, // or div) operators. One use case could be the following. Suppose we have 10 buckets (0..9, 10..19, ..., 90..99) and we wish to check whether two item values fall into the same bucket. If we have just the modulus operator, then we could do something like this: {host:ItemA.last()} - {host:ItemA.last()} % 10 <= {host:ItemB.last()} and {host:ItemB.last()} - {host:ItemB.last()} % 10 <= {host:ItemA.last()} If we have just the integer division operator, then it is even simpler: {host:ItemA.last()} // 10 = {host:ItemB.last()} // 10 Without these operators, it seems non-obvious how the same can be accomplished in Zabbix. |
Comments |
Comment by Aleksandrs Saveljevs [ 2016 Sep 13 ] |
When implementing, remember to choose an appropriate definition for operator behavior with negative numbers: see https://en.wikipedia.org/wiki/Modulo_operation , https://en.wikipedia.org/wiki/Division_(mathematics) , and http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html . |
Comment by Aleksandrs Saveljevs [ 2016 Sep 13 ] |
It might be that introducing a built-in interpreter for a standard language like Lua or Python, as suggested in |
Comment by Alexei Vladishev [ 2021 May 21 ] |
It was implemented in Zabbix 5.4. |