From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: fengchengwen@huawei.com, Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v2 3/3] usertools/telemetry: add help support
Date: Fri, 22 May 2026 14:37:13 +0100 [thread overview]
Message-ID: <20260522133714.133268-4-bruce.richardson@intel.com> (raw)
In-Reply-To: <20260522133714.133268-1-bruce.richardson@intel.com>
While the telemetry infrastructure supported using "/help,/<cmd>" to get
help on specific commands, with the addition of script-specific
commands, we needed better help support to explain the use of FOREACH,
and to allow e.g. "help /<cmd>" using space separation, which is more
intuitive. This patch adds that help support.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
usertools/dpdk-telemetry.py | 61 ++++++++++++++++++++++++++++++++++++-
1 file changed, 60 insertions(+), 1 deletion(-)
diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py
index 8b976160e0..2c88b91517 100755
--- a/usertools/dpdk-telemetry.py
+++ b/usertools/dpdk-telemetry.py
@@ -25,6 +25,26 @@
ALIAS_FILE = ".dpdk_telemetry_aliases"
MAX_ALIAS_EXPANSIONS = 32
+BASIC_HELP_TEXT = """Basic usage:
+ /<command>[,<params>] Send a telemetry command to the app
+ FOREACH ... Run a compound query over list items
+ help Show this help
+ help /<command> Show app-provided help for a command
+ help FOREACH Show FOREACH usage and examples
+ quit Exit the client
+"""
+
+FOREACH_HELP_TEXT = """FOREACH usage:
+ FOREACH /<list_cmd> /<iter_cmd> .<field> [.<field> ...]
+ FOREACH <var> /<list_cmd> /<iter_cmd_with_$var> .<field> [.<field> ...]
+
+Examples:
+ FOREACH /ethdev/list /ethdev/stats .opackets
+ FOREACH /ethdev/list /ethdev/stats .ipackets .opackets
+ FOREACH i /ethdev/list /ethdev/info,$i .name
+ FOREACH i /ethdev/list /ethdev/stats,$i .ipackets .opackets
+"""
+
def load_aliases():
"""Load aliases from $HOME/.dpdk_telemetry_aliases"""
@@ -203,10 +223,49 @@ def handle_foreach(sock, output_buf_len, text, pretty=False):
print(json.dumps(output, indent=indent))
+def command_exists(cmd):
+ """Check if a telemetry command exists in the command list"""
+ return cmd in CMDS
+
+
+def app_help_command_for(target_cmd):
+ """Build a '/help,<command>' query for app-side command help"""
+ if not target_cmd:
+ return None
+ normalized = target_cmd.strip()
+ if not normalized.startswith("/"):
+ return None
+ if not command_exists(normalized):
+ print("Unknown command for help: {}".format(normalized))
+ return None
+ return "/help,{}".format(normalized)
+
+
+def handle_user_help(sock, output_buf_len, text, pretty=False):
+ """Handle local 'help' command and command-specific help lookup"""
+ parts = text.split(None, 1)
+ if len(parts) == 1:
+ print(BASIC_HELP_TEXT, end="")
+ return
+
+ help_arg = parts[1].strip()
+ if help_arg.upper() == "FOREACH":
+ print(FOREACH_HELP_TEXT, end="")
+ return
+
+ cmd = app_help_command_for(help_arg)
+ if cmd is None:
+ print("Usage: help [FOREACH|/<command>]")
+ return
+ send_command(sock, cmd, output_buf_len, echo=True, pretty=pretty)
+
+
def handle_command(sock, output_buf_len, text, pretty=False):
"""Execute a user command if recognized"""
if text.startswith("/"):
send_command(sock, text, output_buf_len, echo=True, pretty=pretty)
+ elif text == "help" or text.startswith("help "):
+ handle_user_help(sock, output_buf_len, text, pretty)
elif text.startswith("FOREACH "):
handle_foreach(sock, output_buf_len, text, pretty)
@@ -340,7 +399,7 @@ def handle_socket(args, path):
def readline_complete(text, state):
"""Find any matching commands from the list based on user input"""
- all_cmds = ["quit"] + list(ALIASES.keys()) + CMDS
+ all_cmds = ["quit", "help"] + list(ALIASES.keys()) + CMDS
if text:
matches = [c for c in all_cmds if c.startswith(text)]
else:
--
2.53.0
next prev parent reply other threads:[~2026-05-22 13:37 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
2026-05-22 13:37 ` Bruce Richardson [this message]
2026-05-29 0:27 ` [PATCH v2 3/3] usertools/telemetry: add help support 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=20260522133714.133268-4-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
/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