R12.1-JA-2025June05
Define a Single-variable Parser
Single-Variable 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 Variable Parser can be 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 version number variable as an example. You can define a Variable Parser to parse version number. Follow the instructions below to define a variable parser step-by-step.
- 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).
- Click the Retrieve button to retrieve sample text, which will be displayed in the input area. For more information about the sources for retrieving command data, see Data Source for Retrieving Data in Parser.
- In the sample config line area, select word from the Sample data area to add line patterns:
- 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.
- Select 6 weeks, 6 days, 10 hours, 38minutes in line 9 from the Sample Data are, then click Parse Variable in the floating tip window. A new line pattern Var Line2 will be created.
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.
- In the Output area, change the variable name to a meaningful one as needed. In the current example: $Version -> $version$var1 -> $uptime
- Click the Apply button to create pattern, then check the output for the previous device version and the uptime.
After this step, you will notice that the Pattern type is automatically set to Single. - Continue to select variables to add new pattern line. 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.
Tip: When you continue to add variable, the newly created line pattern will be in red background, indicating that it can be edited. While the previously created line patterns are disabled and cannot be edited. - In the Output area, click variable $reason in the Output pane to set variable name as $reload_type.
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 variable to fill out the line pattern. - Click the Apply button to update the line pattern, then check the output for load type in the Output area.
- Click the save icon
at the upper-right corner to save the parser.