From: fengchengwen <fengchengwen@huawei.com>
To: Bruce Richardson <bruce.richardson@intel.com>, <dev@dpdk.org>
Subject: Re: [PATCH v2 2/3] usertools/telemetry: support using aliases for long commands
Date: Fri, 29 May 2026 08:25:28 +0800 [thread overview]
Message-ID: <89ca5024-1ffa-4eed-a0d1-6aeb01acf46a@huawei.com> (raw)
In-Reply-To: <20260522133714.133268-3-bruce.richardson@intel.com>
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 <bruce.richardson@intel.com>
> ---
> 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
> +
> +
next prev parent reply other threads:[~2026-05-29 0:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 15:39 [PATCH 0/2] extend interactive telemetry script Bruce Richardson
2026-05-21 15:39 ` [PATCH 1/2] usertools/telemetry: add a FOREACH command Bruce Richardson
2026-05-21 15:39 ` [PATCH 2/2] usertools/telemetry: support using aliases for long commands Bruce Richardson
2026-05-22 0:44 ` [PATCH 0/2] extend interactive telemetry script fengchengwen
2026-05-22 7:51 ` Bruce Richardson
2026-05-22 13:37 ` [PATCH v2 0/3] " Bruce Richardson
2026-05-22 13:37 ` [PATCH v2 1/3] usertools/telemetry: add a FOREACH command Bruce Richardson
2026-05-29 0:17 ` fengchengwen
2026-05-22 13:37 ` [PATCH v2 2/3] usertools/telemetry: support using aliases for long commands Bruce Richardson
2026-05-29 0:25 ` fengchengwen [this message]
2026-05-22 13:37 ` [PATCH v2 3/3] usertools/telemetry: add help support Bruce Richardson
2026-05-29 0:27 ` fengchengwen
2026-06-09 16:13 ` [PATCH v3 0/3] extend interactive telemetry script Bruce Richardson
2026-06-09 16:13 ` [PATCH v3 1/3] usertools/telemetry: add a FOREACH command Bruce Richardson
2026-06-09 16:13 ` [PATCH v3 2/3] usertools/telemetry: support using aliases for long commands Bruce Richardson
2026-06-09 16:14 ` [PATCH v3 3/3] usertools/telemetry: add help support Bruce Richardson
2026-06-09 16:17 ` Bruce Richardson
2026-06-10 1:39 ` [PATCH v3 0/3] extend interactive telemetry script fengchengwen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=89ca5024-1ffa-4eed-a0d1-6aeb01acf46a@huawei.com \
--to=fengchengwen@huawei.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox