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.
1.Click the icon on the taskbar and select New Parser.
2.Keep the default Legacy Device 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.
3.Select CLI Command from the Parser Type list.
4.Enter the Show Process CPU and Show Process Memory commands, and separate them with ||.
5.Click Retrieve and select a Cisco router to retrieve sample data.
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
6.Parse the value of CPU utilization.
1)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.
2)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.
3)Click Save Variable in the Keyword Parser dialog. This variable will be displayed in the variable tree.
4)Follow the above steps to add the variable of the five-minute CPU utilization.
7.Parse the value of memory utilization.
1)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.
2)The Keyword Parser dialog prompts with the Parser field (Used: $int:var1 Free:) auto-identified.
3)Rename the var1 to used_mem in the Variable field.
4)Click Save Variable in the Keyword Parser dialog.
5)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.
8.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: