[dpdk-dev] [PATCH 06/12] usertools: add new telemetry python script

Ciara Power ciara.power at intel.com
Thu Mar 19 18:19:01 CET 2020


From: Bruce Richardson <bruce.richardson at intel.com>

This patch adds a python script that can be used with the new telemetry
socket. It connects as a client to the socket, and allows the user send
a command and see the JSON response.

The example usage below shows the script connecting to the new telemetry
socket, and sending two basic ethdev commands entered by the user.
The response for each command is shown below the user input.

Connecting to /var/run/dpdk/rte/dpdk_telemetry.19707
--> /
{"/": ["/", "/ethdev/list", "/ethdev/stats"]}
--> /ethdev/list
{"/ethdev/list": [0, 1]}
--> /ethdev/stats,0
{"/ethdev/stats": {"rx_good_packets": 0, "tx_good_packets": 0,
<snip>
 "tx_priority7_xon_to_xoff_packets": 0}}

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
Signed-off-by: Ciara Power <ciara.power at intel.com>

---
This is a temporary script for testing purposes. Later versions
of the patchset will include a production ready version, which may
be merged into the existing dpdk_telemetry script.
---
 usertools/test_new_telemetry.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100755 usertools/test_new_telemetry.py

diff --git a/usertools/test_new_telemetry.py b/usertools/test_new_telemetry.py
new file mode 100755
index 000000000..23e879122
--- /dev/null
+++ b/usertools/test_new_telemetry.py
@@ -0,0 +1,30 @@
+#! /usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation
+
+import socket
+import os
+import glob
+import json
+
+def handle_socket(path):
+    print("Connecting to " + path)
+    try:
+        fd.connect(path)
+    except OSError:
+        return
+    text = input('--> ')
+    while (text != "quit"):
+        fd.send(text.encode())
+        reply = json.loads(fd.recv(1024 * 12).decode())
+        print(json.dumps(reply))
+        text = input('--> ')
+    fd.close()
+
+fd = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
+# Path to sockets for processes run as a root user
+for f in glob.glob('/var/run/dpdk/*/dpdk_telemetry.*'):
+  handle_socket(f)
+# Path to sockets for processes run as a regular user
+for f in glob.glob('/run/user/%d/dpdk/*/dpdk_telemetry.*' % os.getuid()):
+  handle_socket(f)
-- 
2.17.1



More information about the dev mailing list