Ad Widget

Collapse

Calculate time since last value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jerrylenk
    Member
    Zabbix Certified Specialist
    • May 2010
    • 62

    #1

    Calculate time since last value

    Hi,

    I have a Zabbix-Trapper-Item that receives Traps from a host at very irregular intervals. They are sent via zabbix sender upon completion of a program, reporting the return code.

    What I want now is an item, that gives me "Minutes since last execution", i. e. "time since last value of the trapper item was received".
    Does anyone have an idea how to calculate that?

    Greetings, Jerry
  • jerrylenk
    Member
    Zabbix Certified Specialist
    • May 2010
    • 62

    #2
    I can think of a mysql script with like
    "SELECT timestamp FROM zabbix.items ..."

    But maybe somebody knows a simpler, more elegant way?

    Comment

    • bradh
      Junior Member
      • Aug 2012
      • 14

      #3
      Jerry,

      I have similar situation with backups that run at different intervals.

      Best solution I have found so far is to create an item that stores the "Success" or "Failure" status of the backup which is updated by zabbix_send.

      I create two triggers off this item. One to alert whenever the item is not equal to "Success". A second trigger that checks nodata(xxx) in combination with time of day and day of week.

      For a simple daily backup where the backup run time might vary by an hour, the trigger is simply <item>.nodata(25h)=1

      Will be watching to see if you find anything better.

      Brad

      Comment

      • jerrylenk
        Member
        Zabbix Certified Specialist
        • May 2010
        • 62

        #4
        Thanks!

        I don't quite understand what the second trigger is for?
        To warn if no backup job was run at all?

        Jerry

        Comment

        • bradh
          Junior Member
          • Aug 2012
          • 14

          #5
          Correct.

          First trigger lets us know if the backup ran but failed.
          {server:item.regexp("^Success")}=0

          Second trigger lets us know if the backup didn't run. For us, this is more important as it's sometimes hard to notices that something is missing.
          {server:item.nodata(25h)}=1

          The second trigger can get complicated if you try to take into account full vs incremental backups and different schedules. It seems possible though using the time and dayofweek functions but the trigger expressions get harder to read. As an example:

          {server:item.nodata(1640m)}=1|({server:item.nodata (250m)}=1&{server:item.time(0)}>081500&{server:ite m.dayofweek(0)}<7)

          This is the best way I've found to handle irregular schedules.

          Comment

          • jerrylenk
            Member
            Zabbix Certified Specialist
            • May 2010
            • 62

            #6
            Cool.
            But plain item.nodata() probably does it for me.

            I understand, the item.time(0) function returns "right now", no matter which item I choose?
            A function like "item.time-of-last-value(#0)" would be nice, just for the fun of it.
            It is in the database, so maybe one day I'll put togethter a script for it.

            Thanks!

            Comment

            Working...