10.1.15.12-06212024
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.
- Go to Parser Library, then click New Advanced Parser from the drop-down menu of a folder. The parser editor will open.
- Keep the default Traditional Devices node type and select Cisco Router from the Device Type list.
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.
- (Optional): Click Advanced to configure the settings for filtering applicable devices as qualified device. For more information, see Qualified Device Filter in Advanced Parser.
- Select CLI Command from the Data Type list.
- Enter the Show Process CPU and Show Process Memory commands, then separate them with ||.
- Click Retrieve and select a device to retrieve sample data. The retrieved data will display in the sample text pane.
Note: The command input supports the commands with variables. For example, if the input command contains variable "$intf", you need to set values for the variables when you retrieve 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 2% 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.
- Highlight the CPU value exactly in the sample data (do not include the spaces before and after the metric), such as 2% of the one-minute CPU utilization, and then click Define Keyword in the floating menu.
- Parse the value of memory utilization.
- Highlight the allocated memory value 8934208 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 pops up with the Parser field (0 $int:var1 8934208 ) 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 the
icon to save the Parser in the Parser Library.
See also: