.. include:: ../common.txt ################ Suggested Steps ################ The |TOOLKIT_CLI| contains built-in steps that can help you to process data in most scenarios to get the correct data you need. In this section, we will give you hints on combining the available parser steps with selector steps you could use immediately right after. .. note:: A parser step converts a data structure into a consumable format for a selector step. That means that the output of a parser is the input of a selector. Make sure you know the output of a given step, to choose correctly the next one. ***************** CLI Parser Steps: ***************** Parse Ifconfig ============== The `Parse Ifconfig `_ has the following input/output data flow: .. code-block:: none Input: str | List[str] Output: dict The selector steps that can take a dictionary as an input are: * `Simple Key `_ * `JSONPath `_ * `JMESPath `_ * `Regex Select Table `_ Parse Line ========== The `Parse Line `_ has the following input/output data flow: .. code-block:: none Input: str Output: Iterable[Any] If you provide arguments while using the Parse Line, you will get a dictionary. The selector steps that can take a dictionary as an input are: * `Simple Key `_ * `JSONPath `_ * `JMESPath `_ * `Regex Select Table `_ Parse Proc/net/snmp =================== The `Parse Proc/net/snmp `_ has the following input/output data flow: .. code-block:: none Input: List[str] | str Output: dict The selector steps that can take a dictionary as an input are: * `Simple Key `_ * `JSONPath `_ * `JMESPath `_ * `Regex Select Table `_ Parse Sectional Rows ==================== The `Parse Sectional Rows `_ has the following input/output data flow: .. code-block:: none Input: List[str] | dict Output: dict The selector steps that can take a dictionary as an input are: * `Simple Key `_ * `JSONPath `_ * `JMESPath `_ * `Regex Select Table `_ Parse Netstat ============= The `Parse Netstat `_ has the following input/output data flow: .. code-block:: none Input: str | List[str] Output: dict The selector steps that can take a dictionary as an input are: * `Simple Key `_ * `JSONPath `_ * `JMESPath `_ * `Regex Select Table `_ Parse Table Column ================== The `Parse Table Column `_ has the following input/output data flow: .. code-block:: none Input: str | List[str] Output: List[dict] The selector step that can take a list of dictionaries as an input is: * `Select Table Item `_ Parse Table Row =============== The `Parse Table Row `_ has the following input/output data flow: .. code-block:: none Input: List[str] Output: dict The selector steps that can take a dictionary as an input are: * `Simple Key `_ * `JSONPath `_ * `JMESPath `_ * `Regex Select Table `_ JC == The `JC `_ should be your preferred parser when you use the |TOOLKIT_CLI|. It converts the output of many standard Unix command outputs to dictionaries or lists of dictionaries. It has the following input/output data flow: .. code-block:: none Input: str | bytes | Iterable Output: dict | list[dict] | Iterable[dict] The selector steps that take a dictionary as an input are: * `Simple Key `_ * `JSONPath `_ * `JMESPath `_ * `Regex Select Table `_ *********************************** Some Examples of Steps Combinations *********************************** Next, you can see some examples on how to combine steps to retrive especific data. Example using the Parse Proc/net/snmp step ========================================== Let's say you need to execute the following command: .. code-block:: none cat /proc/net/snmp Since this command returns the output of the snmp stats, you could parse the data using the *Parse Proc/net/snmp* and select some specific information by using the *JSONPath* selector and get the IcmpMsg data. .. code-block:: yaml low_code: id: procnet version: 2 steps: - ssh: command: cat /proc/net/snmp - parse_proc_net_snmp - jsonpath: value: $..IcmpMsg Example using the Parse Table Column step ========================================= Let's say you need to execute the following command: .. code-block:: none netstat -rn You could parse the data using the *Parse Table Column* and select some specific information by using the *Select Table Item* selector to the Gateway item. .. code-block:: yaml low_code: id: netstat version: 2 steps: - ssh: command: netstat -rn - parse_table_column: skip_lines_start: 1 skip_lines_end: 0 columns: 7 - select_table_item: index: - 1 Example using the Parse Line ============================ Let's say you need to execute the following command: .. code-block:: none /usr/bin/lscpu You could parse the data using the *Parse Line* and select some specific information by using the *Select Table Item* selector to the Model information. .. code-block:: yaml low_code: id: regex_parse_line version: 2 steps: - ssh: command: /usr/bin/lscpu - parse_line: split_type: colon key: from_output - regex_select_table: regex: "Model"