What is parsing
Parsing deals with extracting interested part of information from the specific group of text. It can be command output(Command parsing) or from device configuration(Config parsing).
How to access parsing tool
Building -> Templates -> Parsing test
Here we shall go through simple examples of building parsing templates.
Building Parsing template - show ver
In this example we are looking to extract serial number and nvram size from show ver command output of Cisco_IOS nodes.
(1) Paste the command output under Sample command output
(2) Identify the lines we are looking for information
(3) Paste the lines and replace the text we are looking for with variables(words enclosed within <>).
(4) Parse
(5) See the results under Parsing result the values we are looking for is stored in respective variables.
Building Parsing Template - show cdp neigh detail
In this example we shall extract information from show cdp neigh detail output.
Information we shall be capturing are
Remote device name(rem_name), Local port(loc_port), remote port(rem_port) and remote device ip(rem_ip).
(1) Paste the command output of show cdp neigh detail under Sample command output.
(2) Identify the lines of interest
(3) Copy and paste the identified lines in the above column. Separate the variables and static text.
(4) Parse
(5) Parsing results are visible.
Notice that use of '%' for variable <rem_name>. This makes that variable as a key varaiable.
Since there are many cdp neighbors. Using '%' helps us to fetch specific values of each of the entry.
Creating parsing template
Copy the text derived at step 3 in the above examples and then proceed with below steps.
(1) Build -> Templates -> Templates edit -> (2) Select client type(In this case CMDB) -> (3) Parsing Templates -> (4) New -> (5) Appropriate name to the template -> (6) Template type: command ->(7) Vendor type: Cisco_IOS -> (8) Save
(1) Click the entry under Revisions -> (2) Paste the text derived from Step 3 of Building templates -> (3) Template status: Production -> (4) Save
Below are various options while using parsing templates:
Capabilities
- <variable> only parses single words
- <variable:> parses until it encounters a double space, tab or the end of line
- <variable:test> parses until it encounters the word “test”, surrounded by whitespace, or the end of line otherwise.
- <variable:,> parses until it encounters a single character, which doesn't have to be surrounded by whitespaces. (in this case the 'comma')
- <variable*> will put all text in a single variable
- [header] + all of the above
- %keys + all of the above
- indentation, dealing with multiple levels of indentation.
- |*| ignoring anything else on the line.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article