Ad Widget

Collapse

Dealing w/ discovery rules that discover nothing?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mandyh
    Junior Member
    • Apr 2014
    • 4

    #1

    Dealing w/ discovery rules that discover nothing?

    I am a Oracle DBA and I have written a couple of different LLD discovery rules because we want to monitor different things depending on whether it is a primary database (ex. redo gaps) or a standby database (ex. MRP enabled). Some of our dev machines will occasionally have a mix of primary and standby databases (for example when we do a switchover to standby for maintenance on the primary). Anyway, this is why we need the LLD rules to be flexible.

    The problem is when a machine only has standby databases or only has primary databases. On a host with only primary databases the standby discovery rule doesn't return anything at all to the agent, and therefore Zabbix complains that "Value should be a JSON object." Conversely on hosts with only standby databases the primary discover rule doesn't discover anything and therefore returns nothing to the agent, so in Zabbix the primary LLD discover rule complains with the same message. Is there a graceful way to tell Zabbix "Hey, there is nothing discovered here at the moment so just move along"? I tried sending back a pair of empty strings in JSON format instead of nothing at all, and it really didn't like that and disabled the discovery rule. By sending back nothing the rule stays enabled, but has a red X for status. But it would be nice to see that everything is happy with a green check mark if possible.

    This newbie would appreciate any advice!
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    What about sending a "nonsense" value in the case when you do not want any discovered items and then filter out these via a filter regexp?

    Comment

    • mandyh
      Junior Member
      • Apr 2014
      • 4

      #3
      Interesting idea. I never even noticed the Filter section of a discovery rule before. Okay, I've edited my discovery script to return this string when no databases/items are found:

      {
      "data":[{"{#SID}":"NOTHING"}]
      }"

      So in the Macro I have specified:
      {#SID}

      But I'm not sure what to put in the regexp box. I have tried all of the following:

      !NOTHING
      "!NOTHING"
      ^((?!NOTHING).)*$

      Then I would save, disable/reenable the LLD rule. But so far each time a red X eventually appears in the Error column and it says "Value should be in a JSON format".

      I'm sure I'm doing something wrong.

      Thanks for your help!

      Comment

      • steveboyson
        Senior Member
        • Jul 2013
        • 582

        #4
        Just try "^(NOTHING)$" and "Result is FALSE", that should work.

        Comment

        • mandyh
          Junior Member
          • Apr 2014
          • 4

          #5
          Unfortunately I don't have admin access in Zabbix to create a global regexp (only the sys admin group does). But the discovery rule creation itself has a Filter section that takes a macro and a regexp. I figured out what my problem was, and it turned out not to be related to the regexp. My discovery script was returning an errant double quote in the output when nothing was discovered. I've since fixed that LLD script and now things seem to be working great! No more red X's complaining about JSON format due to nothing being discovered

          Thank you so much for your suggestion!

          Comment

          • mandyh
            Junior Member
            • Apr 2014
            • 4

            #6
            I also just wanted to post the regexp that finally really worked (previously the JSON errors went away but I realized that nothing at all was being discovered, even when databases should be discovered.

            First of all I changed the discovery script to return NULL instead of NOTHING:

            {
            "data":[{"{#SID}":"NULL"}]
            }

            And in the LLD rule Filter section for the Macro I put {#SID}, and the regexp to filter out NULL is:

            [^NULL]

            This command here demonstrates that it works:

            for x in PROD FPRD NULL; do echo $x | grep -E '[^NULL]' || echo "SKIP: $x"; done

            Again, thanks for putting me on the right path.

            Comment

            Working...