[RFC,3/6] usertools: add process-info python script
Checks
Commit Message
From: Bruce Richardson <bruce.richardson@intel.com>
This patch adds a python script that can be used with the process_info
library. It connects as a client to the process_info socket, and allows
the user send a command and see the JSON response.
The example usage below shows the script connecting to the process_info
socket, and sending two basic commands entered by the user. The response
for each command is shown below the user input.
Connecting to /var/run/dpdk/rte/process_info.22103
--> /
{"/":["/","/eal:app_params","/eal:params","/eal:version"]}
--> /eal:version
{"/eal:version":"DPDK 20.02.0-rc0"}
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Ciara Power <ciara.power@intel.com>
---
usertools/test_new_telemetry.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100755 usertools/test_new_telemetry.py
new file mode 100755
@@ -0,0 +1,28 @@
+#! /usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019 Intel Corporation
+
+import socket
+import os
+import sys
+import time
+import glob
+
+def handle_socket(path):
+ print("Connecting to " + path)
+ try:
+ fd.connect(path)
+ except OSError:
+ return
+ text = input('--> ')
+ while (text != "quit"):
+ fd.send(text.encode())
+ print(fd.recv(4096).decode())
+ text = input('--> ')
+ fd.close()
+
+fd = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
+for f in glob.glob('/var/run/dpdk/*/process_info.*'):
+ handle_socket(f)
+for f in glob.glob('/run/user/%d/dpdk/*/process_info.*' % os.getuid()):
+ handle_socket(f)