All of lore.kernel.org
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] usertools/dpdk-telemetry: print name of app when connected
@ 2021-02-16  9:44 Bruce Richardson
  2021-02-16 10:40 ` Burakov, Anatoly
  2021-02-16 11:39 ` [dpdk-dev] [PATCH v2] " Bruce Richardson
  0 siblings, 2 replies; 8+ messages in thread
From: Bruce Richardson @ 2021-02-16  9:44 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Kevin Laatz

When the dpdk-telemetry client connects to a DPDK instance, we can use the
PID provided in the initial connection message to query from /proc the name
of the process we are connected to, and display that to the user. We use
the "cmdline" procfs entry for the query since that is available on both
Linux and FreeBSD (assuming procfs is mounted on the BSD instance).

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 usertools/dpdk-telemetry.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py
index 181859658f..82b91f346f 100755
--- a/usertools/dpdk-telemetry.py
+++ b/usertools/dpdk-telemetry.py
@@ -45,6 +45,11 @@ def handle_socket(path):
         return
     json_reply = read_socket(sock, 1024)
     output_buf_len = json_reply["max_output_len"]
+    pid = json_reply["pid"]
+    if os.path.exists('/proc/' + str(pid) + '/cmdline'):
+        with open('/proc/' + str(pid) + '/cmdline') as f:
+            argv0 = f.read(1024).split('\0')[0]
+            print("Connected to application: '" + os.path.basename(argv0) + "'")
 
     # get list of commands for readline completion
     sock.send("/".encode())
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-25 17:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16  9:44 [dpdk-dev] [PATCH] usertools/dpdk-telemetry: print name of app when connected Bruce Richardson
2021-02-16 10:40 ` Burakov, Anatoly
2021-02-16 11:02   ` Bruce Richardson
2021-02-16 11:13     ` Burakov, Anatoly
2021-02-16 11:39 ` [dpdk-dev] [PATCH v2] " Bruce Richardson
2021-02-16 12:19   ` Burakov, Anatoly
2021-02-17 13:57   ` Kevin Laatz
2021-03-25 17:00     ` Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.