DX NetOps

Expand all | Collapse all

CA.GetRegexp error on non-match

Jump to Best Answer
  • 1.  CA.GetRegexp error on non-match

    Posted 03-22-2019 10:23 AM
      |   view attached

    Hello community,

     

    we're trying to dynamically enrich the Spectrum alarm title for a specific Infoblox alert using parts of one of the event variables (trap varbdinds). Unfortunately, the variable content is (potentially unknown) free form text including even multi-line cases. Obviously we only want to add short meaningful pieces to the alarm title, not just the complete variable content.

    The issue arises when the CA.GetRegexp procedure does not find a match, causing it to exit with error, instead of just returning e.g. an empty text. This causes surrounding functions to error as well leaving us with an empty variable list passed to the follow-up event.

    Does anybody have an idea how to get around this?

     

    Please see the attached tech details for reference.

     

    thanks and regards,

    Raphael



  • 2.  Re: CA.GetRegexp error on non-match

    Posted 03-28-2019 08:50 AM

    There is an "If" function for event procedures. Not 100% sure on the exact usage. Possibly surround the GetRegexp with an If?

     

    Joe



  • 3.  Re: CA.GetRegexp error on non-match
    Best Answer

    Posted 03-28-2019 09:06 AM

    Yes, you need something like

    If ( Regexp(GetEventVariable( {U 7} ), {S \"^\([[:alpha:]].*?\)[:.]\"})),\

            CreateEventWithVariables( \  .... your procedure here),\

            CreateEventWithVariables(\ ... alternate procedure if there is no match ))

     

    The RegExp function will check if the regex matches and returns true/false rather than an error.  If true, you continue with what you already have but if false, you'll need to have something else.  Apologies for the very liberal use of pseudocode but hopefully it makes sense.

     

    -Rob



  • 4.  Re: CA.GetRegexp error on non-match

    Posted 03-29-2019 05:23 AM

    Hi Robert ketro01, all,

     

    I did some testing using that If-statement already but don't remember precisely, if your version was one of those I tested. Maybe I have missed something and will give it another try, once possible.

     

    thanks so far,
    Raphael



  • 5.  Re: CA.GetRegexp error on non-match

    Posted 03-29-2019 11:33 AM

    If you're getting stuck on using "if" in the event procedure, if you don't mind using some additional events, you can use a regular event rule to do the regex check to determine if it should call the event procedure that you have or a different event with an alternate path.



  • 6.  Re: CA.GetRegexp error on non-match

    Posted 04-01-2019 10:47 AM

    Hi ketro01, all,

     

    support DanieleGarzonio came up with the same idea and testing with both your input allowed me to figure out a working solution that raises a follow-up event with all variables passed in either case, regex match and non-match.

    The key basically was to honour the different return value types and use just Regexp to evaluate the If-condition and GetRegexp to extract the pattern once we're in the If-true-branch.

    So that was a classic of not seeing the tree while stumbling through the woods.

     

    Thank you.

     

    regards,

    Raphael