From patchwork Tue Feb 16 09:44:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 87929 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 695BFA0550; Tue, 16 Feb 2021 10:44:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 522D61606BB; Tue, 16 Feb 2021 10:44:31 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 5B83B40690 for ; Tue, 16 Feb 2021 10:44:29 +0100 (CET) IronPort-SDR: Ay+KC0xkfyfETFoGiR9dlhk6L1gk2uHCKq+V0NGhTrtew2Y2DniWoJRXcAcF9gS1sXQGUa9O4E W4E0OJi6ttDQ== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="202033728" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="202033728" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 01:44:27 -0800 IronPort-SDR: I7+3KQAK5Z+3Kb2nih+MXSqiW0oh4qpVFzwTCB5pdRsIO8ajzA6MUKtula03B/QhmLmx+lHkuc oq5kJH5awpfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="364066198" Received: from silpixa00399126.ir.intel.com ([10.237.223.216]) by orsmga006.jf.intel.com with ESMTP; 16 Feb 2021 01:44:25 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Kevin Laatz Date: Tue, 16 Feb 2021 09:44:15 +0000 Message-Id: <20210216094415.28000-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] usertools/dpdk-telemetry: print name of app when connected 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" When the dpdk-telemetry client connects to a DPDK instance, we can use the PID provided in the initial connection message to query from /proc the name of the process we are connected to, and display that to the user. We use the "cmdline" procfs entry for the query since that is available on both Linux and FreeBSD (assuming procfs is mounted on the BSD instance). Signed-off-by: Bruce Richardson --- usertools/dpdk-telemetry.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py index 181859658f..82b91f346f 100755 --- a/usertools/dpdk-telemetry.py +++ b/usertools/dpdk-telemetry.py @@ -45,6 +45,11 @@ def handle_socket(path): return json_reply = read_socket(sock, 1024) output_buf_len = json_reply["max_output_len"] + pid = json_reply["pid"] + if os.path.exists('/proc/' + str(pid) + '/cmdline'): + with open('/proc/' + str(pid) + '/cmdline') as f: + argv0 = f.read(1024).split('\0')[0] + print("Connected to application: '" + os.path.basename(argv0) + "'") # get list of commands for readline completion sock.send("/".encode())