Ad Widget

Collapse

Calculating item's specific value duration

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jacek Sarna
    Junior Member
    • Aug 2025
    • 3

    #1

    Calculating item's specific value duration

    Hello everybody!

    I'm using Zabbix 7.4.2.

    Recently i've been trying to create item that would show me, how long in the past 24 hours other item's (for clarity "ITEM DOOR") value had certain value.

    Some technicalities about ITEM DOOR:
    - main purpose: it checks if door is open (0 - closed, 1 - open);
    - it's HTTP agent type;
    - consists of two ways of gathering information: pulls with interval of 1 minute and traps, whenever door opens or closes. I'm not sure if it's good practice to combine pulls with traps. I've made it like this to make sure, that it gets data (if it's not good way of doing that, i would appreciate some tips : ) ). Precise time of door opening / closing is crucial;
    - it's got simple trigger: last(/door_1/door.status,#1)=1

    I need to create everyday report with information, for how long that door was open. My idea was to create item that would calculate time based on ITEM DOOR, display it on dashboard with some graphs and schedule report every midnight. So far, i've tried to:
    - create calculated item using AVG function multiplying by update interval. Irregular traps are way too good at messing up average. I've tried to tweak it by creating custom AVG using Count, but it still was creating values, that were 10-30% higher than they should be;
    - "problems" widget. It's good addition to dashboard, but it doesn't sum up problems duration;
    - SLA report. It's closest to what i need, but the fact it's showing percentage instead of actual duration also makes it unusable (reports about door are meant for non-technical people, and they prefer easily readable duration).

    I haven't touched Script item type yet, since i'm not really proficient at programing (i'll try it, if there's no way around : ) )

    Has anyone stumbled on problem like that or has an idea, how could it be implemented?
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #2
    I think you could try using a calculated item with the "lastclock" function.
    Click image for larger version

Name:	Screenshot From 2025-08-30 10-38-45.png
Views:	108
Size:	21.8 KB
ID:	506738

    This item should store the timestamp difference between the last value of an item and its previous value. Then, a trigger can evaluate for an abnormal behavior.​
    Note that the interval of the calculated item can affect the time values.
    Perhaps a trigger with expression macros could create more meaningful events.

    Comment

    • Jacek Sarna
      Junior Member
      • Aug 2025
      • 3

      #3
      Thank you markfree for your insight.

      I've modified your proposition creating this:
      Click image for larger version

Name:	image.png
Views:	58
Size:	14.9 KB
ID:	506798​​
      I'm using last() function to filter only status "open". To sum up for how long that door was open in the last 24h i've created another calculated item:

      Click image for larger version

Name:	image.png
Views:	58
Size:	13.1 KB
ID:	506797
      It won't be fully accurate yet (due to update intervals), but i'll give it few days to see if it works in any way.
      I'll post the results here in few days.
      Attached Files

      Comment

      • Jacek Sarna
        Junior Member
        • Aug 2025
        • 3

        #4
        Update:

        At the very base, it works, but it's not accurate at all. I could try tweaking update intervals, but i've thought of another idea.
        We're using Node Red and maybe i could create something using API and/or webhooks to automate history data creation.

        I'll see how it works out and keep posting here.

        Comment

        Working...