Ad Widget

Collapse

Problem getting a negative calculated value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manuel Deschambault
    Junior Member
    • Jan 2026
    • 3

    #1

    Problem getting a negative calculated value

    I want to keep an eye on 3 Kafka folders (web processing). Here is what I have done:
    1. Mounted the kafka folders as "read-only" on my LinuxHelper VM
    2. Written an SNMP extension returning the values of the number of items in the 3 folders as a string in the format x;y;x
    3. Created an SNMP item in Zabbix receiving this string and being polled every minute
    4. Created 3 "Dependent item" items, that extract the proper number from the string (using Preprocessing) as saving it as a "Numeric (float)"
      1. For each of the 3 items, created the two following items (since change items do not keep negative values):
        1. A calculated item (call it last2), showing the 2nd to last value saved as "Numeric (float)"
        2. A calculated item (call it last), showing the last value saved as "Numeric (float)"
    All the above steps work fine, here is where I am stuck and can't seem to find the fix

    I then created another calculated item (call it "Change" set to: last(//Last2) - last(//Last), saved as "Numeric (float)"

    Over the normal operation, the count of kafka files varies, and if the karka count goes from 50 to 30, I do see:
    1. Last2=50
    2. Last=30
    3. The "Change" calculated items should be -20
    But the last calculated item "Change", refuses to show any negative numbers, the graph from the "last values" section only shows positive values, with 0 where values would be negative

    Having negative values for my kafka change folder is critical for me to create a good alert to show a stuck web process where kafka files are no longer processed, i.e. if no negative value in past 30 minutes, send alert
  • kyus
    Senior Member
    • Feb 2024
    • 175

    #2
    If everything is set correctly you should be seeing negative values. And some things that might help you, since you pointed these things:

    Originally posted by Manuel Deschambault
    For each of the 3 items, created the two following items (since change items do not keep negative values)
    In fact, change items do keep negative values, and I strongly suggest you use change(//itemkey) instead (more on this later).

    Originally posted by Manuel Deschambault
    1. A calculated item (call it last2), showing the 2nd to last value saved as "Numeric (float)"
    2. A calculated item (call it last), showing the last value saved as "Numeric (float)"
    You don't really need calculated items to store the previous values of your item. You can always refer to the 2nd to last value using "last(//itemkey,#2)". So your item could be last(//itemkey,#2)-last(//itemkey)

    With that said, I don't recommend it because if you were to have negative values coming from your item (probably not your case), the calculation would get messed up.

    So, I think you should try using the change function directly with your "main" item, without creating those calculated items to store previous values.

    Comment

    Working...