From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7F16EA0583; Thu, 19 Mar 2020 18:36:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6DDAA1C0B6; Thu, 19 Mar 2020 18:35:06 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 660D61C026 for ; Thu, 19 Mar 2020 18:35:04 +0100 (CET) IronPort-SDR: DA7Wl7p/PE5o/ZLkK3gvy6dvA7IwDlCvSh//6PWVoRr82Epjxr0O8Fump3kRnLRNFtmiM/F1eF Y/baKEUFXUNA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2020 10:35:04 -0700 IronPort-SDR: 3MN6n112vleU7VCm37JMuqG4+jVJjuUXpEIBj0J+FJQHOod6XSXpVLzyUL1Uj+nkCH2mKwstYr S7kzUX81Gr5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,572,1574150400"; d="scan'208";a="391872670" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga004.jf.intel.com with ESMTP; 19 Mar 2020 10:35:02 -0700 From: Ciara Power To: kevin.laatz@intel.com Cc: dev@dpdk.org, reshma.pattan@intel.com, Bruce Richardson , Ciara Power Date: Thu, 19 Mar 2020 17:19:01 +0000 Message-Id: <20200319171907.60891-7-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319171907.60891-1-ciara.power@intel.com> References: <20200319171907.60891-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH 06/12] usertools: add new telemetry python script X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Bruce Richardson 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, "tx_priority7_xon_to_xoff_packets": 0}} Signed-off-by: Bruce Richardson Signed-off-by: Ciara Power --- 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