R12.1 Project-2025/11/05

Define a Single-variable Parser

Single-Variable Parser parses a single-value variable (such as the version number, etc.) by anchoring keywords before and after the variable. Each Variable Line Pattern in a Variable Parser is used to parse a variable within the full-text range or to parse multiple variables in one line of text.

Applicable Parser Rules for Single-Variable Parser

    When to Use a Single-Variable Parser

      You can use a Variable Parser when certain variables need a programmable check.

      Define a Variable Parser to Parse the Previous Version Number

      Take the Parser for parsing the version number variable as an example. Follow the instructions below to define a variable parser step-by-step. 

      1. Create a new parser and define the parser name (Click , then change the parser name from "Parser1" to "Version Info") and the definitions for retrieving CLI command data (set to retrieve CLI Command show version on the device US-NYC-SW1). 

      2. Click the Retrieve button to retrieve sample text, which will be displayed in the input area. For more information on retrieving command data sources, see Data Source for Retrieving Data in Parser.
      3. In the sample output, select the text (variable values) from the Sample data area to add line patterns:

        1. Double-click the value of version number15.2 (CML_NIGHTLY_20180510)FLO_DSGS7)  in line 2 from the Sample Data area, then a line pattern (Var Line 1) will be created.
        2. Select 6 weeks, 6 days, 10 hours, 38minutes in line 9 from the Sample Data, then click Parse Variable in the floating tip window. A new line pattern, Var Line2, will be created. 
          Information Tip: The system uses the two words before and after "15.2 (CML_NIGHTLY_20180510FLO_DSGS7)" as keywords to generate the line pattern Version $version, EARLY, using the anchor word closest to the variable as the variable name (Version and EARLY in this example). If the word before or after the variable is "is", “was”, “on”, “of”, “with”, “at”, “under”, “for”, “in”, or “:”, the system will look for one word further.

        3. In the Output area, change the variable name to a meaningful one as needed. In the current example: 
          $Version -> $version
          $var1 -> $uptime

      4.  Click Apply to create the pattern, then check the output for the previous device version and the uptime.

        After this step, the Pattern Type is automatically set to Single

      5. Continue to select variables to add new pattern lines. Select “Last Reload” in line 12, then click Parser Variable in the floating tip window. A new line pattern (Var Line 3) will be created. 

        Information Tip: When you continue to add variables, the newly created line pattern will be in the red background, indicating that it can be edited. The previously created line patterns are disabled and cannot be edited.
      6. In the Output area, click variable $reason in the Output pane to set the variable name as $reload_type.

        Information Tip: To define more variables inside the Variable Parser, repeat the above steps 5-6. You can also click + Field to create an empty line pattern, then parse a variable to fill out the line pattern.

      7. Click Apply to update the line pattern, then check the variable values in the Output area.

         
      8. Click the save icon  at the upper-right corner to save the parser.