On 5/22/2026 9:37 PM, Bruce Richardson wrote:
> Similarly to how shell aliases work, allow specifying of short alias
> commands for dpdk-telemetry.py script. The aliases are read from
> "$HOME/.dpdk_telemetry_aliases" at startup.
>
> Some examples of use from the docs. Alias file contents:
>
> # Basic shortcuts
> ls=/ethdev/list
> names=FOREACH i /ethdev/list /ethdev/info,$i .name
> q=quit
>
> Alias use:
>
> --> ls
> {"/ethdev/list": [0, 1]}
>
> --> names
> [{"i": 0, "name": "0000:
>
> Signed-off-by: Bruce Richardson <[email protected]>
> ---
> doc/guides/howto/telemetry.rst | 34 +++++++++++++++
> usertools/dpdk-telemetry.py | 75 ++++++++++++++++++++++++++++++++--
> 2 files changed, 105 insertions(+), 4 deletions(-)
>
> diff --git a/doc/guides/howto/telemetry.rst b/doc/guides/howto/telemetry.rst
> index 4bf48c635e..072289aec8 100644
> --- a/doc/guides/howto/telemetry.rst
> +++ b/doc/guides/howto/telemetry.rst
> @@ -130,6 +130,40 @@ and query information using the telemetry client python
> script.
> - With loop variable: returns an array of objects containing the loop
> variable field and requested value fields.
>
> + * Use command aliases.
> +
> + The telemetry script can load aliases at startup from::
> +
> + $HOME/.dpdk_telemetry_aliases
How about add one parameter to specific aliases file location
> +
> + Each alias entry must be in ``alias=command`` format.
> + Empty lines and lines starting with ``#`` are ignored.
> +
> + Example alias file::
> +
> + # Basic shortcuts
> + ls=/ethdev/list
> + names=FOREACH i /ethdev/list /ethdev/info,$i .name
> + q=quit
> +
> + Alias behavior is intentionally similar to shell aliases:
> +
> + - The first token of the entered input is checked for an alias match.
> + - If matched, that first token is replaced with its expansion.
> + - Alias expansion is recursive (aliases can expand to other aliases).
> + - Expansion has a safety limit to prevent infinite loops.
> +
> + Examples::
> +
> + --> ls
> + {"/ethdev/list": [0, 1]}
> +
> + --> names
> + [{"i": 0, "name": "0000:16:00.0"}, {"i": 1, "name": "0000:16:00.1"}]
> +
> + --> q
> + # exits the client
> +
>
> Connecting to Different DPDK Processes
> --------------------------------------
> diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py
> index 2de10cff69..8b976160e0 100755
> --- a/usertools/dpdk-telemetry.py
> +++ b/usertools/dpdk-telemetry.py
> @@ -21,6 +21,70 @@
> SOCKET_NAME = "dpdk_telemetry.{}".format(TELEMETRY_VERSION)
> DEFAULT_PREFIX = "rte"
> CMDS = []
> +ALIASES = {}
> +ALIAS_FILE = ".dpdk_telemetry_aliases"
> +MAX_ALIAS_EXPANSIONS = 32
> +
> +
> +def load_aliases():
> + """Load aliases from $HOME/.dpdk_telemetry_aliases"""
> + aliases = {}
> + home = os.environ.get("HOME")
> + if not home:
> + return aliases
> +
> + alias_path = os.path.join(home, ALIAS_FILE)
> + if not os.path.isfile(alias_path):
> + return aliases
> +
> + try:
> + with open(alias_path) as alias_file:
> + for line_num, line in enumerate(alias_file, start=1):
> + entry = line.strip()
> + if not entry or entry.startswith("#"):
> + continue
> + if "=" not in entry:
> + print(
> + "Warning: ignoring malformed alias at
> {}:{}".format(alias_path, line_num),
> + file=sys.stderr,
> + )
> + continue
> + name, command = entry.split("=", 1)
> + name = name.strip()
> + command = command.strip()
> + if not name or not command:
> + print(
> + "Warning: ignoring malformed alias at
> {}:{}".format(alias_path, line_num),
> + file=sys.stderr,
> + )
> + continue
> + aliases[name] = command
> + except OSError as e:
> + print("Warning: failed to read {}: {}".format(alias_path, e),
> file=sys.stderr)
If load OK, please add one promote at begin:
Loaded xxx command aliases, see `help alias` for detail
> +
> + return aliases
> +
> +