Advanced Message Prcessing

Download Report

Transcript Advanced Message Prcessing

Message Source
Configuration:
Pattern Matching
Section Overview
• Pattern Matching Rules and Expressions
• Using Variables
• Pattern Matching Examples
• opcpat - The pattern matching tester
2
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
Pattern Matching Expressions
• Standard Characters
• Expression Anchoring
• Expression Matching Multiple Characters
• Alternative
• Bracket Expression
• Not Expression
• Numerical Expression
• Mask Character
3
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
Pattern Matching Rules
• Parsing of input & pattern strings
•
•
•
•
All expressions are parsed form left to right
*
as little as possible
#, @, S
as much as possible
Delimiters can be used for performance and
readability
• Matched pattern can be assigned to a variable
*#@S
Commonly used pattern
matching expressions
4
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
Assigning Sub-patterns to Variables
• Simple assignment
Eg <*.fname> could assign “Logfile” to fname
• Using the period (.) within brackets
Eg <[<@>file.tmp].fname> could assign “Logfile.tmp” to fname
• Using OR (|) within brackets
Eg <[Error|Warning].sev> assigns either Error or Warning to sev
• Using multiple levels of brackets
Eg <[Error[<#.n><*.msg>]].complete> assigns n and msg to complete
5
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
Examples
• Pattern Strings
Error
panic
[logon|logoff]
^getty: <*.msg> errno<*><#.errnum>$
^errno[ |=]<#.errnum> <*.errtext>
^hugo:<*>:<*.uid>:
^Warning: <*.text> on node <@.node>$
6
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
Question 1
Example 1:
Input String:
errno: 125 - device does not exist
Pattern:
Result:
Found error with 125 which means device does not exist
7
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
Question 2
Example 2:
Match any failed SU after 8:00pm
Input Strings from /var/adm/sulog:
SU 03/25 08:14 - ttyp2 usr-root
SU 03/25 20:14 - ttyp3 andreas-root
not matched
matched
Pattern:
8
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
opcpat - The pattern matching tester
SYNOPSIS
opcpat [ -h ] [ -i ] [ -q ] [ -fp <patternfile> ] [ -fv <valuefile> ] [-o
<outfile> ]
# cd /opt/OV/bin/OpC/utils
# ./opcpat
using singlebyte mode
Enter a pattern and the separator characters used for <@>, <S>
pattern (<RETURN> to exit): <@.var1><@.var2>
separators:
******** next pattern ********
Pattern: "<@.var1><@.var2>" using seps " "
value (<RETURN> for new pattern): 123456
"" var1:"12345" var2:"6" ""
Pattern: "<@.var1><@.var2>" using seps " "
value (<RETURN> for new pattern):
9
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]
Pattern Matching in Conditions
Match the
incoming pattern
to variables
Use variable as
parameters to alter
message text
Use parameters
as part of
running actions
10
Message Source Configuration:
Pattern Matching
[vpo_mgr_src_pattern]