R12 Publication-2025July16
Define a Paragraph Parser
A Paragraph Parser extracts the essential data in recurring lines of text and places it into a tabular shape.
Applicable Parser Rules for Paragraph Parser
When to Use a Paragraph Parser
A Paragraph Parser converts variables across multiple sections of the raw text into a table data structure, so diagnosis against each row can be exacted.
Five Steps to Define a Paragraph Parser
To define a paragraph variable, you need five major steps:
- Create a new parser, then define the settings to collecting command show interface data on device BJ-L2-coreB, and use the data as sample text.
- Select the Paragraph pattern for the new parser.
- Define one or more ID Line Patterns, which will be used as the key to identify recurring paragraphs. The default and mandatory ID Line Pattern is labeled as ID Line A, which divides lines of text into paragraphs. Optionally, you can add more ID Line Patterns (B, C, D…) as filters to filter out unqualified paragraphs.
- Define Variable Line Patterns to parse variables inside each recurring paragraph identified by ID Line Pattern.
- Click Apply to save the parser definitions.
- Click the
icon at the upper-right corner to save the Parser.
Define a Paragraph Parser to Parse Interface Data
Take the parsing of interface information as an example. You can define a Paragraph Parser to parse interface information. Follow the instructions below to define a paragraph parser for parsing variables based on the CLI command data (show interface) collected on the device BJ-L2-Core-A.
- Create a new parser, then define the parser name (Click the
icon, then change the parser name from "Parser1" to "Interface Info") and the definitions for retrieving CLI command data (set to retrieve CLI Command "show interface" on the device BJ-L2-Core-A).
- Click the Retrieve button to retrieve the sample text. For more information about the sources for retrieving command data, see Data Source for Retrieving Data in Parser.
- Select Paragraph from the Type drop-down menu, then a paragraph pattern will be created.
- Parser variables to create ID Line Pattern and Var Line Pattern: Define the paragraph identifier in ID line pattern to identify recurring paragraphs, then define var line pattern to parser variables in the recurring paragraph.
- In the Parser Input area, double-click "Vlan1", and "up" in line 2 to parser interface variables and interface status data, then an ID Line A containing multi-string variables $var1 and $var2 will be created.
As you double-click a word in the Parser Input area and variable is parsed, the searchlight will appear to indicate the matching relationship between the selected text and the parsed variable.Tip: You can manually add more ID lines by Clicking +Field > +ID Line. Otherwise, a new var line will be created if you continue to select variable in the Parser input area. In this example, we will only add one ID line. - In the Parser Input area, double-click “1504” in line 4 to parse MTU variable. A var line1 containing multi-string variable $int: MTU will be created.
- In the Parser Input area, and double-click “0” beside CRC in line 19 to parse CRC variable. A var line1 containing multi-string variable $crc will be created.
- In the output area, change the variable name and variable type as follows:
Change variable name: $var1 -> $interface; $var2 -> $status
Change variable type: Change the status of $status to mstring.
- In the Parser Input area, double-click "Vlan1", and "up" in line 2 to parser interface variables and interface status data, then an ID Line A containing multi-string variables $var1 and $var2 will be created.
- Click the Apply button to confirm the parser definitions. Then check the output for interface information in the output area. The parsed result of a paragraph parser is in a tabular shape. The variables defined in ID line patterns, variable line patterns.
Note: After clicking the Apply button, the parser UI background will turn to blue color to indicate that the parser definitions in the current pattern have been confirmed. - Click the save icon
to save the parser.