Two types of functions (LineByKeyword and LineByVariable) can be added by inserting the original line texts.
Entrance: To launch this function, click the + Parse Lines link from the Output area.
Engineers can get the original line texts by three methods.
Parse the Line of Variable
Parse the lines containing the selected one or more variables (Pattern Sample: LineByVariable[$confg]: $var1, LineByVariable[$confg]: $var1, $var2).
- This method can be applied in single pattern, paragraph pattern and collector pattern.
- The scope of selectable variables is all the variables defined in the current pattern.
The following two examples illustrate how to create line pattern with function containing one parsed variable or more than one parsed variables.
Example 1: Parse the lines containing a single variable, e.g., parse acl config per line.
- Create a parser and name it "Access List ".
- Define the settings for collecting configuration file data. In this example, select Configuration as the retrieved data and select the device US-BOS-R1.
- Double-click "1" in line 417 to parse the variable “access_list” first in the Auto Parser mode.
- Click +Parse Lines, then define the Parse Lines Settings in the pop-up dialog:
- Set the name to “acl_config”, The default name is "Lines1".
- Keep the default option “The line of variable”, then select “$access_list” by checking the checkbox.
- You can preview the pattern command to be created in the pattern field.
- Click Apply to close the Parse Lines dialog. After this step, you will notice that a var line containing the variable selected in step 4 is created.
- Then check the output to view the new added data column in the Output pane.
- Click Apply at the upper-right corner to confirm all the settings.
Example 2: Parse two variables in different lines. In this example, we will parse lines including interface variable and MTU variables.
- Create a parser and name it "Interface and MTU Data".
- Define the settings for collecting CLI Command data. In this example, select "CLI Command" of "show interface" as the retrieved command data and select the device US-BOS-R1 to retrieve data on it.
- Click "Ethernet0/0" in line 2, then continue to click "1500" in line 5 to parse the variables “interface” and “MTU” first in the Auto Parser mode.
The original parsed variable can be modified. For example, click "&var1" in the output pane, then change the name to a more suitable one (Interface). - Click +Parse Lines in the Output area, then define Parse Lines settings in the pop-up dialog:
- Set the name to “intf_mtu”,
- select “The line of variable”, then select “$interface” and “$MTU”.
- You can preview the pattern command to be created in the pattern field.
- Click Apply to close the Parse Lines dialog. After this step, you will notice that a var line containing the two variables selected in step 4 is created.
- Check the parsed lines including "interface" and "MTU" variables for each interface in the output.
- Click Apply at the upper-right corner to confirm all the settings.
Parse the Lines Between Variables
Parse the lines in a range defined by two variables, or from a variable to the end of the paragraph (Pattern Sample: LineByVariable[$confg]: $var1-$var2, LineByVariable[$confg]: $var1-).
- This method can be applied in single pattern, paragraph pattern and collector pattern.
- The scope of selectable variables is all the variables defined in the current pattern.
Example 1: In this example, parse the lines between two variables, e.g., parse the basic metric of OSPF interface
- Create a new parser and name it "OSPF_Interface".
- Define the settings for collecting CLI Command data. In this example, select "CLI Command" of "show ip ospf interface" as the retrieved data and select the device US-BOS-R1 to retrieve data on it.
- Click "Loopback0" in line 2 to parse the variables “$interface”, then continue to double-click "1" in line 4 to continue to parser variable “$ospf_id” in Auto Parser mode.
The system will automatically assign the variable name "var1" and "ID" for the two parsed variables, respectively. In this example, you can change the variable names to more meaningful ones in the Output area.- Click the variable name "$var1", then change it to "$interface" in the pull-down window.
- Click the variable name "$ID", then change it to "$ospf_id"
- Click +Parse Lines, then define Parse Lines settings in the pop-up dialog: Set the name to “ospf_metric”. Select The line between option, then select “$interface” and “$ospf_id” to define the scope of the matched original lines. Check the parsed lines between the two selected variables for each interface in the output.
- Set the name to “ospf_metric”.
- Select “The line between”, then select “$interface” and “$ospf_id” to define the scope of the matched original lines. Check the parsed lines between the two selected variables for each interface in the output.
- Click Apply to save the Parse Lines settings, then you will notice that Var Line 2 is created.
- Check the parsed lines between the two selected variables for each interface value in the output.
- Click Apply at the upper-right corner to confirm all the settings.
Example 2: You can select a variable and “End” to define the scope of the original text. In this example, we will parse the lines from a variable to the end, e.g., parse OSPF config.
- Parse the variable “$ospf_id” first in Auto Parser mode.
- Parse Line Settings: Set name to “ospf_config”, select “The line between”, then select “$ospf_id” and “End”. Check the parsed lines in the output.
Note: To correct the parsed result, the “End Line” needs to be included.
Parse the Lines of Keyword
Parse the lines containing the specified keywords or variable template (Pattern Sample: LineByKeyword[$confg]: access-list, LineByKeyword[$confg]: standby <%$standby_id%>).
- The method can be applied to single pattern, paragraph pattern and collector pattern.
- The scope of selectable variables is all the variables defined in the current pattern. Variable is inserted as a variable template to reference a pre-defined variable.
Example 1: Parse the lines containing one keyword, e.g., parse all access-list to one variable.
- Add an empty single variable pattern first. Do not need to define the variables.
- Parse Line Settings: Set the name to “acl_config”, select the “The line contains keyword” option, then input “^access-list”. Check the parsed ACL configurations in the output.
Example 2: Parse the lines containing keywords (insert a variable template). In this example, we will parse acl config for each access-list id.
- Parse the variable “access_list” first in a collector pattern.
- Parse Line Settings: Set the name to “acl_config”, select “The line contains keyword” option, then input “^access-list”, then click
to select “$access-list”, then continue to input “$_dummy”. The final keyword is “^access-list <%$access_list%> $_dummy”. Check the parsed ACL configurations for each access_list id in the output.