From patchwork Tue Feb 16 11:50:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 87932 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 3394EA0558; Tue, 16 Feb 2021 12:59:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9ECF9160737; Tue, 16 Feb 2021 12:59:58 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 735D440690 for ; Tue, 16 Feb 2021 12:59:57 +0100 (CET) IronPort-SDR: LXqI9UGVGBar96cu9tXF9LvGyFhTeKMZwwGG2Ze2LLR7CBcl7E+7LgdQ0MojoBoFEhJ8whfkK0 rj3S50OMp3aQ== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="170527711" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="170527711" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 03:59:56 -0800 IronPort-SDR: cqKcwz/8F7RSi+W2tUbSI49HyOzcMUPT3+YFzBJfN+OWaA4OfIMGrhrmK4eaeSStsJnt/T7od9 qaB6T42W7wXw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="512509967" Received: from silpixa00399838.ir.intel.com ([10.237.213.35]) by orsmga004.jf.intel.com with ESMTP; 16 Feb 2021 03:59:54 -0800 From: Kevin Laatz To: dev@dpdk.org Cc: bruce.richardson@intel.com, anatoly.burakov@intel.com, Kevin Laatz Date: Tue, 16 Feb 2021 11:50:08 +0000 Message-Id: <20210216115008.65205-1-kevin.laatz@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210216105625.59844-1-kevin.laatz@intel.com> References: <20210216105625.59844-1-kevin.laatz@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3] 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 --- v2: Minor changes to comments and argument naming v3: Use os.path.join for formatting paths --- 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..e68192f93f 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 os.path.join('/var/run/dpdk', fp) + return os.path.join(os.environ.get('XDG_RUNTIME_DIR', '/tmp'), 'dpdk', 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(os.path.join(rdir, 'dpdk_telemetry.{}'.format(TELEMETRY_VERSION)))