From patchwork Tue Feb 16 10:56:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 87930 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68241A0558; Tue, 16 Feb 2021 12:11:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1AB28160721; Tue, 16 Feb 2021 12:11:44 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id C8BC740690 for ; Tue, 16 Feb 2021 12:11:42 +0100 (CET) IronPort-SDR: jCe6C/IMMELRHMhgD8NiChy1vvQOSb2V9CDaN1dioWR/CVVLGhHXT7QbbSD2CNSMPewTmpx0En YYDb1Oes4cgg== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="182993087" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="182993087" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 03:11:41 -0800 IronPort-SDR: OTvdXKY33Ash/G9RqbDyBHQhZG6oSudE321zbr28a6kZVpD2q7WqA8et1sw+XOixcdpWHpUnzL 7VR5+STPH0kA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="438881574" Received: from silpixa00399838.ir.intel.com ([10.237.213.35]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2021 03:11:40 -0800 From: Kevin Laatz To: dev@dpdk.org Cc: bruce.richardson@intel.com, Kevin Laatz Date: Tue, 16 Feb 2021 10:56:25 +0000 Message-Id: <20210216105625.59844-1-kevin.laatz@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210215155051.8659-1-kevin.laatz@intel.com> References: <20210215155051.8659-1-kevin.laatz@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] usertools/dpdk-telemetry: add file-prefix cmdline argument X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Currently the dpdk-telemetry.py script connects to all running DPDK apps consecutively. With the addition of this file-prefix argument, we can limit the amount of information returned providing improved consumability and precision to the user. Signed-off-by: Kevin Laatz Reviewed-by: Bruce Richardson Tested-by: Bruce Richardson --- v2: Minor changes to comments and argument naming --- usertools/dpdk-telemetry.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py index 181859658f..2bdee65694 100755 --- a/usertools/dpdk-telemetry.py +++ b/usertools/dpdk-telemetry.py @@ -12,6 +12,7 @@ import glob import json import readline +import argparse # global vars TELEMETRY_VERSION = "v2" @@ -70,14 +71,21 @@ def readline_complete(text, state): return matches[state] +def get_dpdk_runtime_dir(fp): + """ Using the same logic as in DPDK's EAL, get the DPDK runtime directory + based on the file-prefix and user """ + if (os.getuid() == 0): + return "/var/run/dpdk/{}".format(fp) + return "{}/dpdk/{}".format(os.environ.get('XDG_RUNTIME_DIR', '/tmp'), fp) + + readline.parse_and_bind('tab: complete') readline.set_completer(readline_complete) readline.set_completer_delims(readline.get_completer_delims().replace('/', '')) -# Path to sockets for processes run as a root user -for f in glob.glob('/var/run/dpdk/*/dpdk_telemetry.%s' % TELEMETRY_VERSION): - handle_socket(f) -# Path to sockets for processes run as a regular user -for f in glob.glob('%s/dpdk/*/dpdk_telemetry.%s' % - (os.environ.get('XDG_RUNTIME_DIR', '/tmp'), TELEMETRY_VERSION)): - handle_socket(f) +parser = argparse.ArgumentParser() +parser.add_argument("-f", "--file-prefix", \ + help="Provide file-prefix for DPDK runtime directory", default="rte") +args = parser.parse_args() +rdir = get_dpdk_runtime_dir(args.file_prefix) +handle_socket("{}/dpdk_telemetry.{}".format(rdir, TELEMETRY_VERSION))