1 of 1 people found this helpful
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:
will be ['ORAPX10A']
and the the output of this expression:
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)
$NEW.status == OPEN AND
$NEW.mc_object_class == 'ORA_ASM_CUSTOM_TBSP'
$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]);
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.
Thanks a lot Brendan, I'm trying this modification.
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.