Ad Widget

Collapse

Zabbix and fuzzytime trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tlacroix
    Member
    • Dec 2013
    • 30

    #1

    Zabbix and fuzzytime trigger

    Hey there,

    I'm having troubles to understand how the fuzzytime trigger works. Here's my situation.

    I have a bash script that checks the warranty end date of a few servers
    This script is ran once a week, sunday night.
    The response I have is a date such as 2018-01-01

    My script converts this date to a timestamp (with a date -d 2018-01-01 +%s), then pushes the value (zabbix_sender) to a numeric item (unsigned)
    I have associated the following trigger, to fire if the warranty end date is higher than 90 days: {Template X:timestamp.fuzzytime(90d)}=1

    First time I manually ran the script, it worked.
    Now, it does not. Whatever the number of days in my trigger, no alarm is triggered anymore for this template. Alarms already triggered are not switched from "PROBLEM" to "OK"

    Did I miss something with this trigger?
    Hints appreciated!

    Thanks!

    (Zabbix 4.2.1)
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #2
    Did I understand it correctly that you're sending it the timestamp of 2018-01-01, which is
    Code:
    $ TZ=UTC date +%s -d 2018-01-01
    1514764800
    in this case fuzzytime(90d) would return 0 and trigger expression would evaluate to false (0=1) and the trigger should go to OK from PROBLEM state, right? Please show the last values of the item, that didn't make the trigger to go "OK".

    Comment

    • tlacroix
      Member
      • Dec 2013
      • 30

      #3
      Hey dimir,

      Any value does the same behavior
      As it's a key, i can (and just did) manually update the key to be 1514764801 then 1514764802
      The trigger (currently OK) did not switch to "PROBLEM"

      Comment

      • dimir
        Zabbix developer
        • Apr 2011
        • 1080

        #4
        Your trigger expression translates to "alert if received timestamp is less than 90 days old". You send the value "1514764801" which is 1st of January 2018. It's not less than 90 days old, that is why no alert. Send it the value "1570492800" and it will switch to PROBLEM state.

        Comment

        • tlacroix
          Member
          • Dec 2013
          • 30

          #5
          Sooo what trigger shoud i set, to be warned when I have only 90 days left (or less) of warranty ?
          Last edited by tlacroix; 08-10-2019, 17:18.

          Comment

          • dimir
            Zabbix developer
            • Apr 2011
            • 1080

            #6
            Yes. From the manual about fuzzytime(sec):
            Returns:
            1 - difference between item value (as timestamp) and Zabbix server timestamp is less than or equal to sec seconds
            0 - otherwise
            So you want to alert when it returns 0.

            Comment

            • tlacroix
              Member
              • Dec 2013
              • 30

              #7
              OK, so as i edited my previous answer, correct answer (for future persons in need) is {Template X:timestamp.fuzzytime(90d)}=0

              I will try that
              Thank you dimir.

              Comment

              • tlacroix
                Member
                • Dec 2013
                • 30

                #8
                mmh, so it has not worked as expected

                I have a server with the timestamp 1613862000 (2021-02-21) and the trigger is on PROBLEM
                .. and another server with the timestamp 1370642400 (2013-06-08) in PROBLEM too (normal behavior)
                Last edited by tlacroix; 08-10-2019, 17:37.

                Comment

                • dimir
                  Zabbix developer
                  • Apr 2011
                  • 1080

                  #9
                  Both timestamps you provided differ from current time more than 90 days.

                  Comment

                  • tlacroix
                    Member
                    • Dec 2013
                    • 30

                    #10
                    Yes both timestamps differ from more than90 days, but in the past and in the future, but as said in the documentation,
                    1 - difference between item value (as timestamp) and Zabbix server timestamp is less than or equal to sec seconds
                    I understood from the
                    less than or equal to
                    that the PROBLEM would not occur if it's
                    more than

                    Comment

                    • dimir
                      Zabbix developer
                      • Apr 2011
                      • 1080

                      #11
                      What function fuzzytime(sec) returns is just a number. If the difference between value and current time (it doesn't matter, future or past) is less than sec, it returns 1. Otherwise 0. This number is not triggering anything.
                      Now if you got that part, it's time to define what is a problem on the right side of trigger expression. If you want to trigger a problem if difference is over 90 days, you compare the number with 0:
                      Code:
                      {Template X:timestamp.fuzzytime(90d)}=0
                      This trigger expression literally means "fire a trigger if the received value is over 90 days in the past or over 90 days in the future".
                      Last edited by dimir; 09-10-2019, 10:59.

                      Comment

                      • tlacroix
                        Member
                        • Dec 2013
                        • 30

                        #12
                        That makes sence
                        So fuzzytime is not the trigger I have to use, as i want to have "only in the past"

                        Thank you for your time!

                        Comment

                        • dimir
                          Zabbix developer
                          • Apr 2011
                          • 1080

                          #13
                          You can manually compare with current time and get notifications only when input is more than 90 days in the past using the following expression:
                          Code:
                          {Template X:timestamp.now()}-{Template X:timestamp.last()}>90d
                          And just to clear something out, fuzzityme() (as well as now() and last() in the above expression) are not triggers, they are trigger functions, meaning functions that can be applied to item values and used in trigger expressions.

                          Comment

                          Working...