This section introduces how to choose an appropriate parsing method when defining a parser.
The Keyword method is used to parse data with a single instance only, such as CPU usage, and version number.
Example: Use the Keyword method to parse a version number.
1.Enter the show version command and retrieve sample data in the parser editor page.
2.Highlight the version number exactly in the sample data and click Define Keyword in the floating menu.
3.The Keyword Parser dialog prompts with both the parser pattern and the variable type auto-identified. Rename the variable from var1 to Version.
4.Click Save Variable.
The Paragraph method is used to parse data with multiple instances, such as collisions and CRC errors for each interface in the returned output of the show interface command.
Example: Use the Paragraph method to parse the value of interface MTU.
1.Enter the show interface command and retrieve sample data in the parser editor. A sample output is as follows:
Bos-Core1-Tr>show interface
Vlan1 is up, line protocol is up
Hardware is EtherSVI, address is 0024.1358.1540 (bia 0024.1358.1540)
MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,
.............
Vlan10 is up, line protocol is up
Hardware is EtherSVI, address is 0024.1358.1542 (bia 0024.1358.1542)
Internet address is 10.83.10.254/24
MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,
............
2.Highlight the MTU value 1500 in the sample data and click Define Keyword in the floating menu. The Keyword Parser dialog prompts.
3.Click Define Variable Under Paragraphs in the pop-up dialog to go to the Paragraph Parser dialog.
Tip: The Paragraph Parser is used when a command output matching a keyword multiple times and each keyword having identical paragraph formatting such as beginning with …is..., line protocol is.
4.Specify the Paragraph Identifier to identify the start of a new paragraph for each variable.
1)Highlight Vlan 1 is up, line protocol and click Set Paragraph Identifier in the floating menu.
2)The Paragraph Identifier includes the keywords which are always same and the sample values that change. Replace it with $intf is $status, line protocol.
3)Press the Enter key on your keyboard to apply the paragraph identifier.
5.Rename the variable from var1 to MTU.
6.Optional: Configure advanced settings.
Click Advanced to configure more settings: 1)To further split the paragraph manually, use one of the following two ways: ▪Enter the ending keyword of the paragraph and select whether to Exclude the ending line in the paragraph. ▪Select the Set _ lines as a paragraph check box, and enter the number of lines you want to include after the line of the variable. 2)To fill an empty variable by copying the value of the last variable, you can enable the last check box and select the applied variable from the drop-down menu. 3)Click OK. |
---|
7.Click Save Variable.
This variable MTU will be displayed under a paragraph parser in the variable tree.
The Table method is used to parse table-formatted data, such as NDP table.
Example: Use the Table method to parse the OSPF neighbors of a device.
1.Enter the show ip ospf neighbor command and retrieve sample data in the parser editor page. A sample output is as follows:
BST,POP1>show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
172.24.255.9 1 FULL/ - 00:00:32 172.24.33.140 Serial0
172.24.255.10 1 FULL/DR 00:00:32 172.24.32.6 Ethernet1
172.24.31.2 1 FULL/ - 00:00:39 172.24.32.1 Serial1
2.Highlight the table in the sample data and click Define Table in the floating menu. The Table Parser dialog prompts with the table headers identified as the variables.
3.Optional: Configure advanced settings.
Click Advanced to configure more settings: 1)Select how to align the table data or how to split the column if it is not table-formatted: ▪Left Aligned — left-align the table data. ▪Right Aligned — right-align the table data. ▪Range of Characters — address the table header by counting characters from 0, such as 0;5;13. ▪Number of Words — address the table header by counting the number of words, such as 1;2;1. 2)Specify the end of table parser. If you want to end the table parser in an empty line, enter ^$. 3)To ignore a few first rows of the table data, you can select the Skip _ lines from header check box and enter the number of lines. 4)To fill an empty variable value by copying the value of the last variable, you can enable the last check box and select the applied variable from the drop-down menu. |
---|
4.Click Save Variable. The variables will be displayed under a table parser in the variable tree.
The Filter method is used to filter data based on conditions.
Example: Use the Filter method to parse passive interfaces of a routing protocol.
1.Enter the show ip protocols command and retrieve sample data in the parser editor page.
2.Figure out the beginning line and ending line of the contents to be filtered, highlight your interesting contents (the beginning line and ending line information should be included) and click Define Filter in the floating menu.
3.The Filter Parser dialog prompts with the beginning line and ending line auto-identified and filled. Rename the variable from filter1 to eigrp_passive.
4.Optional: Configure advanced settings.
Click Advanced to configure the conditions for the filter: 1)Select Contains or Not Contains from the drop-down menu and enter the keyword below. 2)Select the filter method: ▪Filter out all matched lines — address all the matches within the filter scope; if unselected, the filter will stop as soon as the first match is found. ▪Exclude the beginning line — take the beginning line out of the filter scope. ▪Exclude the ending line — take the ending line out of the filter scope. 3)Click OK. |
---|
5.Click Save Variable.
6.Add a nested table parser under the filter parser:
1)Select the node Filter($eigrp_passive) in the Parser Tree, and select Table.
2)Enter passive_interfaces in the Name field.
3)Enter the header of the table Passive in the Header field.
4)Click Apply and a node Table($passive_interfaces) is added under the node Filter($eigrp_passive).
The Script method is much more flexible and usually used for complex configuration cases. The following sample case is to define a simple script parser.
1.Retrieve sample data of a configuration file.
2.Select Script and enter the Python script.
3.Click Add Parser.