From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A4A73A0550; Tue, 16 Feb 2021 11:44:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64A6C1606DA; Tue, 16 Feb 2021 11:44:12 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 73DB440690 for ; Tue, 16 Feb 2021 11:44:10 +0100 (CET) IronPort-SDR: 8YmkKNUL+ns06Jutu8kYwdr0KW00p7PA5zaE0f4+We3dMCBqeP1IlNBw4BjbZJSrirNi7dJ7if M53uYiOHmuAg== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="161991034" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="161991034" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 02:44:08 -0800 IronPort-SDR: YgXJhODRM3dOBwen3fWhokC/Be6Z5s3+WYlaTbrV0Qa+f3CdyfMuMmFYJFEV0D+VfpmPRueHh/ 07SSYyaitI5w== X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="399458766" Received: from wardmich-mobl.ger.corp.intel.com (HELO [10.213.232.191]) ([10.213.232.191]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 02:44:06 -0800 To: Kevin Laatz , dev@dpdk.org Cc: bruce.richardson@intel.com References: <20210215155051.8659-1-kevin.laatz@intel.com> From: "Burakov, Anatoly" Message-ID: <6e7c73a7-ae87-6e5c-c098-5828ad7e260f@intel.com> Date: Tue, 16 Feb 2021 10:44:05 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20210215155051.8659-1-kevin.laatz@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [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" On 15-Feb-21 3:50 PM, Kevin Laatz wrote: > 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 > --- > 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) You *really* don't like os.path.join, do you :D For the code, this is what EAL does too, so looks fine to me. Acked-by: Anatoly Burakov > + > + > 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)) > Again with the raw path concatenation... -- Thanks, Anatoly