From patchwork Mon Feb 15 15:50:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 87921 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 2D4C2A054F; Mon, 15 Feb 2021 16:57:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F20516067A; Mon, 15 Feb 2021 16:57:55 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id A7B6F406FF for ; Mon, 15 Feb 2021 16:57:53 +0100 (CET) IronPort-SDR: X4+0fcWI5aK0JZ8jqLx4Rcpv0aD3ZAD1qwE8vMQ2WtKE1FRhjQcYWuY1N+XhXYprkkDHvvriR7 Gj7dLp9wPCVg== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="162462331" X-IronPort-AV: E=Sophos;i="5.81,181,1610438400"; d="scan'208";a="162462331" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2021 07:57:52 -0800 IronPort-SDR: +t15+ty96VG0PAVXSP08V4NAoala8NcP44QURn2x3348GgFgVfyYBaqv498jTRBweEJA655wVK dfkXV75WrZ8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,181,1610438400"; d="scan'208";a="399126302" Received: from silpixa00399838.ir.intel.com ([10.237.213.35]) by orsmga008.jf.intel.com with ESMTP; 15 Feb 2021 07:57:51 -0800 From: Kevin Laatz To: dev@dpdk.org Cc: bruce.richardson@intel.com, Kevin Laatz Date: Mon, 15 Feb 2021 15:50:51 +0000 Message-Id: <20210215155051.8659-1-kevin.laatz@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] 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 Acked-by: Anatoly Burakov --- usertools/dpdk-telemetry.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py index 181859658f..8cafcf74a6 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,20 @@ def readline_complete(text, state): return matches[state] +def get_dpdk_runtime_dir(fp): + """ 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))