2023-Nov-03-R11.1a
Create a CLI Command Parser
This section introduces how to create a CLI Command Parser to extract key metrics in a CLI command output.
Example: Parse the CPU and memory utilization of a Cisco router.
- Keep the default Traditional Devices node type and select Cisco Router from the Device Type list. By default, the All Device Types option is selected.
Tip: The system also supports defining a Parser to retrieve and parse SDN data through APIs. See Creating an API Parser to get details about API Parser.
- Select CLI Command from the Parser Type list.
- Enter the Show Process CPU and Show Process Memory commands, and separate them with ||.

- Click Retrieve and select a Cisco router to retrieve sample data.
- Parse the value of CPU utilization.
- Highlight the CPU value exactly in the sample data (do not include the spaces before and after the metric), such as 1% of the one-minute CPU utilization, and then click Define Keyword in the floating menu.
- The Keyword Parser dialog prompts with the following fields auto-identified.
- Sample — the sample command line where the variable stays.
- Parser — defines keywords and where a variable is located. The Keyword Parser minute: $var1; five is created automatically. It contains the keywords minute: and ; five that always stay the same, and the variable $var1, which varies in different devices.
- Variable — the variable defined in the Parser. To change the auto-created variable name to a more meaningful name, rename the variable, such as from var1 to CPU_1m.
- Click Save Variable in the Keyword Parser dialog. This variable will be displayed in the variable tree.
- Follow the above steps to add the variable of the five-minute CPU utilization.
BJ*POP>show process cpu
CPU utilization for five seconds: 1%/0%; one minute: 1%; five minutes: 1%
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
1 0 2 0 0.00% 0.00% 0.00% 0 Chunk Manager
BJ*POP>show process memory
Processor Pool Total: 132718560 Used: 15225656 Free: 117492904
I/O Pool Total: 52428800 Used: 5754848 Free: 46673952
- Parse the value of memory utilization.
- Highlight the used memory value 15225656 in the sample data (do not include the spaces before and after the metric), and then click Define Keyword in the floating menu.
- The Keyword Parser dialog prompts with the Parser field (Used: $int:var1 Free:) auto-identified.
- Rename the var1 to used_mem in the Variable field.
- Click Save Variable in the Keyword Parser dialog.
- Follow the above steps to add the variable of the free memory space. Then both the CPU and memory utilization are displayed in the variable tree.

- Click Save. The Parser will be saved in the Parser Library.
Note: The command input supports the commands with variables. You need to set values for the variables when you retrieve data.
See also: