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 1B908A0548; Thu, 9 Sep 2021 17:56:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D76F340041; Thu, 9 Sep 2021 17:56:31 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id C23E34003E for ; Thu, 9 Sep 2021 17:56:29 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="201025356" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="201025356" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 08:56:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="694198498" Received: from silpixa00399952.ir.intel.com ([10.55.129.13]) by fmsmga006.fm.intel.com with ESMTP; 09 Sep 2021 08:56:27 -0700 From: David Hunt To: dev@dpdk.org Cc: ciara.power@intel.com, David Hunt Date: Thu, 9 Sep 2021 16:56:25 +0100 Message-Id: <20210909155625.24581-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] usertools/telemetry: add non-interactive mode 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" Add non-interactive mode to dpdk-telemetry.py so that a query string can be supplied on the command line, and script dumps out data and exits. Handing for calling from scripts. Signed-off-by: David Hunt --- usertools/dpdk-telemetry.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py index e04aa04702..5ce772d49d 100755 --- a/usertools/dpdk-telemetry.py +++ b/usertools/dpdk-telemetry.py @@ -48,7 +48,7 @@ def get_app_name(pid): return None -def handle_socket(path): +def handle_socket(path, query): """ Connect to socket and handle user input """ sock = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET) global CMDS @@ -69,13 +69,17 @@ def handle_socket(path): sock.send("/".encode()) CMDS = read_socket(sock, output_buf_len, False)["/"] - # interactive prompt - text = input('--> ').strip() - while text != "quit": - if text.startswith('/'): - sock.send(text.encode()) - read_socket(sock, output_buf_len) + if (query != ""): + sock.send(query.encode()) + read_socket(sock, output_buf_len) + else: + # interactive prompt text = input('--> ').strip() + while text != "quit": + if text.startswith('/'): + sock.send(text.encode()) + read_socket(sock, output_buf_len) + text = input('--> ').strip() sock.close() @@ -104,6 +108,8 @@ def get_dpdk_runtime_dir(fp): parser = argparse.ArgumentParser() parser.add_argument('-f', '--file-prefix', \ help='Provide file-prefix for DPDK runtime directory', default='rte') +parser.add_argument('-q', '--query', \ + help='run this query and exit', default='') args = parser.parse_args() rdir = get_dpdk_runtime_dir(args.file_prefix) -handle_socket(os.path.join(rdir, 'dpdk_telemetry.{}'.format(TELEMETRY_VERSION))) +handle_socket(os.path.join(rdir, 'dpdk_telemetry.{}'.format(TELEMETRY_VERSION)), args.query) -- 2.17.1