3 Replies Latest reply on Jan 8, 2020 1:47 PM by Brendan Murray

    match_regex preventing "Error 1001" events

    Alexandre Akio
      Share This:

      I created the below rule to correlate alarms for similar hostnames, for example orapx10a and orapx10b. When the rule compares a no-matching condition for orapx10a and svrhx01,  the rules throws an exception and generates a new event with the message "ERROR 1001 OCCURRED DURING PROCESSING OF EVENT  19235583: EVALUATION OF FUNCTION MATCH_REGEX(SVRHX01,''([A-Z]*[0-9]*)[ABCDE]'','''') FAILED "

       

      The matching and no-matching conditions are expected , so I would like to avoid the 1001 error Event. Is there any way to perform this?

      new correlateOiTablespaceEv: ALARM ($NEW)

              where [

                      $NEW.status == OPEN AND

                      $NEW.mc_object_class == 'ORA_ASM_CUSTOM_TBSP'

                    ]

                      updates ALARM ($ORIG)

                      where [

                              $ORIG.status == OPEN,

                              $ORIG.mc_object_class == $NEW.mc_object_class,

                              $ORIG.mc_parameter == $NEW.mc_parameter

                            ]

                      {

                         if (match_regex($ORIG.hostname,'([A-Z]*[0-9]*)[ABCDE]','') == match_regex($NEW.hostname, '([A-Z]*[0-9]*)[ABCDE]','') AND match_regex($ORIG.mc_object, '([0-9A-Z_]*)_[0-9a-z.]*', '') == match_regex($NEW.mc_object, '([0-9A-Z_]*)_[0-9a-z.]*', '')) then

                         {

                              $NEW.status = ACK;

                              $ORIG.msg = concat([$ORIG.msg, ' : ', $NEW.mc_object]);

                              opadd($NEW,'correlateOiTablespaceEv', $ORIG.hostname);

                              opadd($ORIG,'correlateOiTablespaceEv', $ORIG.hostname);

                         };

                      }

      END

        • 1. Re: match_regex preventing "Error 1001" events
          Brendan Murray

          Hi Alexandre,

           

          I believe what you're seeing is a symptom of a data type mismatch error. You are using the match_regex/4 form of match_regex which extracts one or more fields using regex capture groups, indicated by the parentheses. If the match succeeds, the output of the function is a LIST_OF STRING data type. However, if the match fails, I believe the output of the function is a Boolean data type, i.e. a logical "False".

           

          Here is what I think is happening:

           

          If $ORIG.hostname = 'ORAPX10A' and $NEW.hostname = 'SVRHX01', the output of this expression:

           

               match_regex($ORIG.hostname,'([A-Z]*[0-9]*)[ABCDE]','')

           

          will be ['ORAPX10A']

           

          and the the output of this expression:

           

               match_regex($NEW.hostname, '([A-Z]*[0-9]*)[ABCDE]','')

           

          will be a logical False, because the match will fail since there is no final alpha character in the SVRHX01 hostname.

           

          This means your if statement will be comparing two different data types, a LIST  (with only one element) and a Boolean.

           

          if(['ORAPX10A'] == False)

           

          Most programming languages, including MRL, will not allow you to do this. I think this is why you are getting the ERROR 1001 event. It is a symptom. The root cause is the data type mismatch.

           

          I am not absolutely sure this is what's happening, but I think it's very likely. Regardless, I can show you how to prevent it.

           

          In general, I recommend only using match_regex if there is no other way to solve the problem. That's because match_regex exacts a high performance cost on the cell. Used excessively, or inefficiently, it can significantly slow down event processing. There are lots of MRL string functions and operators that allow you to do many of things that regular expressions can do. And they are more efficient.

           

          However, sometimes match_regex is the only solution. If you must use match_regex, I would try separating the regex match from the string comparison. It will take a series of nested if statements. You would first test that the two hostnames match the pattern and only do the string capture and comparison if both hostnames match the pattern.

           

          Here is an example. (Note that I have removed your comparison of the mc_object slots for the sake of simplicity.)

           

          new correlateOiTablespaceEv: ALARM ($NEW)

           

               where [

                    $NEW.status == OPEN AND

                    $NEW.mc_object_class == 'ORA_ASM_CUSTOM_TBSP'

                      ]

                    updates ALARM($ORIG)

           

                    where [

                         $ORIG.status == OPEN,

                         $ORIG.mc_object_class == $NEW.mc_object_class,

                         $ORIG.mc_parameter == $NEW.mc_parameter

                          ]

                         {

                            # Check if both hostnames fit the pattern with a simple match test and no capture groups.

           

                            if match_regex($ORIG.hostname,'[A-Z]*[0-9]*[ABCDE]','') AND match_regex($NEW.hostname, '[A-Z]*[0-9]*[ABCDE]','') then

           

                               # Yes, they both fit the pattern. Now extract the capture groups and compare them.

                               {

                                   if match_regex($ORIG.hostname,'([A-Z]*[0-9]*)[ABCDE]','') == match_regex($NEW.hostname, '([A-Z]*[0-9]*)[ABCDE]','') then

           

                                   # The extracted strings match, update the events

                                   {

                                        $NEW.status = ACK;

                                        $ORIG.msg = concat([$ORIG.msg, ' : ', $NEW.mc_object]);

                                        opadd($NEW,'correlateOiTablespaceEv', $ORIG.hostname);

                                        opadd($ORIG,'correlateOiTablespaceEv', $ORIG.hostname);

                                   };

                              }

                         }

          END

           

          This may not be the best solution, but it's the only one I can come up with for now. It ensures that both match_regex functions in the second if statement will succeed. This, in turn, ensures that both sides of your == comparison will be the same data type, thereby preventing the ERROR 1001 event.

           

          Regards,

           

          Brendan

          1 of 1 people found this helpful
          • 2. Re: match_regex preventing "Error 1001" events
            Alexandre Akio

            Thanks a lot Brendan, I'm trying this modification.

             

            Regards,

            Alexandre

            • 3. Re: match_regex preventing "Error 1001" events
              Brendan Murray

              You're welcome, Alexandre. If you feel this answers your question, don't forget to mark your post as "Answered". That will help other people who have the same question/problem to find the solution.

               

              Regards,

               

              Brendan