IP Adapter parsers
Unlike the Logfile Adapter, the SNMP Adapter, and the Perl EventLog for Windows Adapter, which have their own dedicated parsers, the IP Adapters can use any one of the following parsers that are included with the BMC Event Adapters.
Specifying a CSV parser
The CSV parser, MA::Parser::CSV, is a pluggable parser that parses a data stream into records (newline), in which each record is a comma-separated value list. The parser returns each value as a token to the mapper.
To specify the CSV parser
- Using a text editor, open the mcxa.conf file.
- In the section of the file that describes the adapter that you want to use with the CSV parser, add the following line:
Parser = parsername In the parser section of the mcxa.conf file, define parser parsername.
The following table describes the parameters that you can modify in the parser definition:
CSV parser parametersParameter
Description
FieldSeparatorA set of characters that will be used as a delimiter
Optional
Default: comma (, )KeepEmptyRecordsIndicates whether empty records are formatted as tokens and passed to the mapping function
Required
Valid values:- 1 - Tokenize empty records
- 0 - Discard empty records (Default)
RecordNegFilterA regular expression that acts as a criterion to which each parsed record is compared
If the criterion is included in the record, the record is discarded.
OptionalRecordPosFilterA regular expression that acts as a criterion to which each parsed record is compared
If the string is included in the record, the record is formatted as a token and passed to the mapping function.
OptionalRecordSeparatorRegular expression used to break a data stream into separate records
The resulting record is returned in the $data variable, which can then be used in the MAP file to refer to the entire record as one field. The $data variable is provided automatically. You cannot rename it.
Optional
Default: \r?\nVarPrefixVariable prefix used by the mapper Each token will be returned as prefix0... prefixn.
Optional
Default: varlog
Default variables sent to the mapper are named varlog0, varlog1.The following figure shows a sample parser definition for a parser named MyParser.
Sample CSV parser specification example[MyParser]
Engine = MA::Parser::CSV
FieldSeparator = "," # Default
KeepEmptyRecords= 0 # Discard Empty Records
RecordNegFilter = "(test|dummy) event"
RecordPosFilter = "(ERROR|WARNING)"
VarPrefix = "token" # Return token<0>... token<n>- Save and close the mcxa.conf file.
Specifying a Fixed-width (column) parser
The fixed-width parser, MA::Parser::FixedWidth, is a pluggable parser that parses a data stream into records. From each record, a field is extracted based on a fixed-width format.
To specify the fixed-width parser
- Using a text editor, open the mcxa.conf file.
- In the section of the file that describes the adapter that you want to use with the fixed-width parser, add the following line:
Parser = parsername In the parser section of the mcxa.conf file, define parser parsername.
The following table describes the parameters that you can modify in the parser definition.
Fixed-Width parser parametersParameter
Description
FieldDefinitionsA numerical pair that specifies which data is used in a field
The first number in the pair specifies from which character in the string to begin collecting data. The second number specifies how many consecutive characters are to be included in the field.
For more information, see Defining Fields.
RequiredKeepEmptyRecordsIndicates whether empty records are formatted as tokens and passed to the mapping function required
Valid values:
- 1 - Tokenize empty records
- 0 - Discard empty records (Default)
RecordNegFilterA regular expression that acts as a criterion to which each parsed record is compared
If the criterion is included in the record, the record is discarded.
OptionalRecordPosFilterA regular expression that acts as a criterion to which each parsed record is compared
If the string is included in the record, the record is formatted as a token and passed to the mapping function.
OptionalRecordSeparatorRegular expression used to break a data stream into separate records
The resulting record is returned in the $data variable, which can then be used in the MAP file to refer to the entire record as one field. The $data variable is provided automatically. You cannot rename it.
Optional
Default: \r?\nTrimLeadingWSRemoves leading white space, if any, from fields required
Valid values:
- 1 - Removes white space (Default)
- 0 - Does not remove white space
TrimTrailingWSRemoves trailing white space, if any, from fields required
Valid values:
- 1 - Removes white space (Default)
- 0 - Does not remove white space
VarPrefixVariable prefix used by the mapper Each token will be returned as prefix0... prefixn.
Optional
Default: varlog
Default variables sent to the mapper are named varlog0, varlog1, .The following figure shows a sample parser definition for a parser named MyParser.
Fixed-width parser specification example[MyParser]
Engine = MA::Parser::FixedWidth
RecordSeparator = "\r?\n"
FieldDefinitions = "0:10,5:10,15:20"
KeepEmptyRecords = 0
TrimLeadingWS = 1
TrimTrailingWS = 1
VarPrefix = "token" # Return token<0>... token<n>- Save and close the mcxa.conf file.
Defining Fields
The contents of each field are determined by a pair of numbers. Each record from which the field is extracted is a string of data. The first field number indicates the starting position in the record at which the string field begins. The second number indicates the length of the string.
Defining a single field
The first character of the record is zero (0 ). A starting number of 5 indicates that the string begins with the sixth character in the record string.
Either number in the field specification can include a negative number. The field length position can include an asterisk wildcard (* ).
- When the starting point (the first number) is negative, the starting position is determined from the end of the record.
- When the field length (the second number) is negative, the end point of the string is calculated by counting back that number of characters from the end of the string and including everything between the starting point and the end point.
- Both the starting point and the length can be negative values.
- When the length is an asterisk (* ), all characters from the starting point to the end of the record string comprise the field string. Use the asterisk when you do not know the record field length but want to select all of it from the starting point that you specify.
Defining Multiple Fields
Each record can contain multiple fields. Example for their order is as follows:
<START1>:<LENGTH1>[, <START2>:<LENGTH2>[, <STARTn>:<LENGTHn>[...]]]
Specifying record and field separated parser
The Record and Field Separated parser, MA::Parser::Separator, is a pluggable parser that parses a data stream into user-definable records. Each record is then converted into a token using a user-defineable field separator.
To specify the Record and field separated parser
- Using a text editor, open the mcxa.conf file.
- In the section of the file that describes the adapter that you want to use with the record and field separated parser, add the following line:
Parser = parsername In the parser section of the file, define parser parsername.
The parameters of the parser definition that you can modify are described in the following table:
Record and field separated parser parametersParameter
Description
FieldSeparatorRegular expression used to break a record into multiple fields
Required
Default: \s+ (separates on any instance of white space)KeepEmptyRecordsIndicates whether empty records are formatted as tokens and passed to the mapping function
Required
Valid values:- 1 - Tokenize empty records
- 0 - Discard empty records (Default)
RecordNegFilterA regular expression that acts as a criterion against which each parsed record is evaluated
If the criterion is included in the record, the record is discarded.
OptionalRecordPosFilterA regular expression that acts as a criterion to which each parsed record is compared
If the string is included in the record, the record is formatted as a token and passed to the mapping function.
OptionalRecordSeparatorRegular expression used to break a data stream into separate records
The resulting record is returned in the $data variable, which can then be used in the MAP file to refer to the entire record as one field. The $data variable is provided automatically. You cannot rename it.
Optional
Default: \r?\nTrimLeadingWSTrims the leading white space from the record before applying RecordSeparator, which is achieved using the split function
In this parser, TrimLeadingWS does not trim the white space from each FIELD after the RecordSeparator has been applied.VarPrefixVariable prefix used by the mapper. Each token will be returned as prefix0... prefixn.
Optional
Default: varlog
Default variables sent to the mapper are named varlog0, varlog1, .The following figure shows a sample parser definition for a parser named MyParser.
Record and Field Separated Parser Specification Example[MyParser]
Engine = MA::Parser::Separator
RecordSeparator = "\r?\n"
FieldSeparator = "\s+"
KeepEmptyRecords = 0 # Discard Empty Records
RecordNegFilter = "(test|dummy) event"
RecordPosFilter = "(ERROR|WARNING)"
VarPrefix = "token" # Return token<0> ... token<n>- Save and close the mcxa.conf file.