Parsing values from the commands

Created by Sanjay Kumar, Modified on Fri, 6 Sep at 1:27 AM by Sanjay Kumar

Parsing purpose

Parsing deals with extracting interested part of information from the specific text.  The text can be command output(Command parsing) or from device configuration(Config parsing).
In this article we are dealing with Command parsing.

Parse_cmd syntax/usage

Parse_cmd is the scenario command that is used to perform parsing.
Below arguments to be passed while using Parse_cmd in the scenarios
  • -n <node>: the node in question
  • -r <request>: a request to send to a node, for example "show interface brief"
  • -t <template>: a command parsing template





In this example we would be extracting the serial number and nvram size from the devices.

Building Parsing template

     Refer to the article Building Parsing Templates .  As per the article we have built a parsing template named show_ver

Building the scenario

    Create a new scenario named Parsing_test1
     (1)Operate -> Scenarios -> (2) New (3) Name:Parsing_test1-> (4) Text:
     <%cmd> = Parse_cmd -n <node> -r "show version" -t show_ver
     log -m "Serial number of the <node> is <serial_no%cmd>"
     log -m "NVRAM size of the <node> is <nvram%cmd>"
     (5) Save
     

Executing the Scenario   

      (1) Operate -> New Jobs -> CMDB/YCE Jobs (based on the type of the node) -> (2) Select the node -> (3) Add list -> (4) Next
            
           
           
    (1) Change the task name to Parse_cmd_test1 -> (2) Save Job as: Give an appropriate name to the Job -> (3) Save -> (4) now -> (5) Schedule
           

 Verifying output

      To verify the output we need to access the job logs.  Open a duplicate or another tab.
      (1) Operate -> Job Status -> Job logs -> (2) Refer to the files on nyeve of the job.
     

 This pop-ups a new page of Job log file.  If we scroll through the <job_id> log file, we can see the serial number and nvram values retrieved from the node using the parsing command.

      

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article