Ad Widget

Collapse

Help with a trigger after 2 failures

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dpeterson
    Junior Member
    • Apr 2014
    • 26

    #1

    Help with a trigger after 2 failures

    Hello,

    I was hoping someone can help with a trigger I am trying to write. I need the condition in this trigger to fail twice before it sends an alert or is "triggered" for lack of a better word.

    Here is the trigger:
    Code:
    {Template Web:webstatus.regexp(up)}=0
    As of now the script that is referenced here returns either a value of "up" or "down". I was hoping to get this trigger to flag if a status that is not "up" is received two times in a row (this item is set to update every 5 minutes). Any help is much appreciated.
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    Since your item returns text ("up" or "down"), you have fewer options for trigger functions than you would if your item returned an integer. For items that have a small set of distinct states, I prefer to write items so that they return an integer and then define a value mapping in Zabbix so that it's easy to see that e.g. 0=down, 1=up, etc. This also makes graphing easier.

    Barring that, and if "down" and "up" are the only possible outputs from your webstatus, then does

    Code:
    {Template Web:webstatus.regexp("up",#2)}<>1
    do it? If I'm reasoning correctly, this condition should be true when neither of the last 2 outputs match "up".

    Comment

    • dpeterson
      Junior Member
      • Apr 2014
      • 26

      #3
      Originally posted by tim.mooney
      Since your item returns text ("up" or "down"), you have fewer options for trigger functions than you would if your item returned an integer. For items that have a small set of distinct states, I prefer to write items so that they return an integer and then define a value mapping in Zabbix so that it's easy to see that e.g. 0=down, 1=up, etc. This also makes graphing easier.

      Barring that, and if "down" and "up" are the only possible outputs from your webstatus, then does

      Code:
      {Template Web:webstatus.regexp("up",#2)}<>1
      do it? If I'm reasoning correctly, this condition should be true when neither of the last 2 outputs match "up".
      Thanks for the recommendation Tim. I can change the item to return an integer value instead (it's just a custom script I wrote). If I do this, what would be my options for the trigger?

      Comment

      • tim.mooney
        Senior Member
        • Dec 2012
        • 1427

        #4
        If you look at the trigger functions documentation, you'll see that there are more functions that accept an integer, so in general you have more options. It's also easier to produce graphs.

        In this particular case, you probably don't need to change it. My comment was more of a "general advice" based on my experiences with Zabbix.

        Comment

        • dpeterson
          Junior Member
          • Apr 2014
          • 26

          #5
          I appreciate the feedback. I looked over the documentation, and I went ahead and changed the script to return integer values of 0 & 1 (0=down, 1=up). I created this trigger:

          Code:
          {Template Web:webtatus.count(#2,1,eq)}=0
          Edit: Following up to say that I have tested this trigger this afternoon, and it's working as intended. Thanks for the recommendations and suggestions.
          Last edited by dpeterson; 27-03-2020, 00:06.

          Comment


          • tim.mooney
            tim.mooney commented
            Editing a comment
            You're welcome!
        Working...