Add parser from the Config and CLI command, and define the variables via Visual Parser. Visual Parser supports the following four types of variable definition. See Visual Parser for more details.
Add the following four types of variables via visual parser to NI:
Text parser is used to match specified lines of text. For example, to verify that the specific configuration or CLI command output does not change in the future, you can define a text parser to parse specified lines of text and compare the live data with baseline. See step 4 and 5 in Adding Config and CLI Command for detailed definition.
Keyword parser is used to parse a single-value variable (such as version number, etc.) by anchoring keywords before and after the variable. Each Variable Line Pattern in a keyword parser can be used to parse a variable within the full-text range or parse multiple variables in one line of text. See Define a Simple Variable Parser for more details.
A paragraph parser is used to extract the essential data in recurring text lines and place it into a tabular shape. The parsed variables of a paragraph parser are a table. The variables defined in ID line patterns, variable line patterns, and parent line patterns (optional) will be formed as table columns.
1.Retrieve sample text.
3.Define ID Line Pattern: anchor the paragraph identifier to identify recurring paragraphs.
2)Define a string-type variable by replacing FastEthernet0/1 with $intf.
3)Define a multi-string variable by replacing up with $mstring:phy_state.
1)Select Full-duplex, 100Mb/s, media type is 10/100BaseTX in the Sample area and click the arrow to duplicate it as an Variable Line 1.
2)In the Variable Line 1 field, replace Full-duplex, 100Mb/s, 10/100BaseTX with $duplex(Full-duplex|Auto-duplex), $speed(100Mb/s|Auto-speed).
3)Select 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored in the Sample area and click the arrow to duplicate it as an Variable Line 2.
4)In the Variable Line 2 field, replace 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored with $input_errors input errors, $crc CRC, $frame frame, $overunn overrun, $ignored ignored.
5.Preview the parsed result of sample text, and then click Apply to save the paragraph parser.
Table parser is used to parse table-formatted text, such as NDP table, VRF table, OSPF neighbors, etc. With a table parser, you can address the line of table headers in the raw text and then leverage column separator to adjust the table's column width manually.
1.Retrieve sample text.
2.Select a parser type by clicking Add Table.
3.Select the line of table header in the Sample area, and click the arrow to duplicate the text in the Table Header Line and Column Separator field.
5.Preview the parsed result of sample text, and click Apply.