R11.0a-March2023

Define Variables

You can copy a verified Parser or Parser in the library in the Related Parser area. If no related Parser exists, you can add a new Parser.

Add Parser from the Config and CLI command and define the variables via Visual Parser. Visual Parser supports five types of variable definitions: Variable, Paragraph, Table, Text, and Collector. See Visual Parser for more details.
 

Add the following four types of variables via visual Parser to NI:

Add Variable

A keyword parser parses 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 Variable Parser for more details.

Add Paragraph

A paragraph parser extracts the data in recurring text lines and places them 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.
  2. Select a parser type by clicking Add Paragraph and clicking on the input box of the target ID Line.

  3. Define ID Line Pattern: anchor the paragraph identifier to identify recurring paragraphs.
    1. Select an interface line of text in the Sample area, and click the arrow to duplicate it as an ID Line A.
    1. Define a string-type variable by replacing Ethernet0/0 with $intf.
    1. Define a multi-string variable by replacing up with $mstring:phy_state.
    1. Define a multi-string variable by replacing up with $mstring:proto_state.
  1. Define Variable Line Pattern: parsing variables inside each recurring paragraph and sub-paragraph identified by ID Line Pattern.

    1. Select Full-duplex, 100Mb/s, media type is 10/100BaseTX in the Sample area and click the arrow to duplicate it as a 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 a 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.
  2. Preview the parsed result of sample text, and then click Apply to save the paragraph parser.

Add Table

Table parser parses table-formatted text, such as NDP table, VRF table, OSPF neighbors, etc. You can address the line of table headers in the raw text and use the column separator to adjust the table's column width.

  1. Retrieve sample text.
  2. Select a parser type by clicking Add Table.
  3. Select the line of the table header in the Sample area, and click the arrow to duplicate the text in the Table Header Line and Column Separator field.
  4. In the Table Column Variables area, select variables required to parse, rename them, and select their types.
  5. Preview the parsed result of the  sample text and click Apply.

Add Text

The text parser matches 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 the baseline. See steps 4 and 5 in Adding Config and CLI Command for detailed definitions.

Add Collector

The collector parser group finds all matching items based on the defined keywords, automatically group them, and parses the required variables based on the grouping.

  1. Retrieve sample text
  2. Select a parser type by clicking Add Collector.

  3. Define the ID Line, which will be used as the keyword to identify recurring groups.
  4. Define Variable Line Patterns to parse variables inside each recurring group identified by ID Line Pattern.

The parsed result of a collector parser is in a tabular shape. The variables defined in ID line patterns, variable line patterns, and parent (optional) will be formed as table columns.