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.

  1. Go to Parser Library, then click New Advanced Parser from the drop-down menu of a folder. The parser editor will open.

  2. Keep the default Traditional Devices node type and select Cisco Router from the Device Type list.

    Information 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.
  1. (Optional): Click Advanced to configure the settings for filtering applicable devices as qualified device. For more information, see Qualified Device Filter in Advanced Parser
  2. Select CLI Command from the Data Type list.

  3. Enter the Show Process CPU and Show Process Memory commands, then separate them with ||.
  4. Click Retrieve and select a device to retrieve sample data. The retrieved data will display in the sample text pane. 

    Information 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.

  5. 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 2% 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.
  1. Parse the value of memory utilization.

    1. 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.
    2. The Keyword Parser dialog pops up with the Parser field (0 $int:var1 8934208 ) 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.

  1. Click the icon to save the Parser in the Parser Library.

 

See also: