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 13D87A00C2; Fri, 14 Oct 2022 17:29:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD66C42D89; Fri, 14 Oct 2022 17:29:46 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 3490642C6E for ; Fri, 14 Oct 2022 17:29:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665761385; x=1697297385; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=p4lICUsB2ECORZuqLx4midMP12vBXiw9id3Hhel1ea8=; b=IEvfYEilDuGdsLLTZEeoFKuALqKhA0tz6AV/u2wlIlRt17e1j9ctgZDI W6B39DZ7nq/uuCYFb0W5Fb0HzwZ6x4niCQhy0aE99TrWZiPHYOw1k1i+n c0oRCfa1VlKOD+I8Yxi7sldEZ/xbVXnt0HGuD2rTz5lGoytpGq8r2xFfM hqdAzKxie8XRsfhyANGPFfHmQrJ00WBzuG7f1+vSYdbTGv7UWm06weDDF JkCMmhXdJAu0iNK/F7DYvTMYiINrEOLyAlRpMQfKEtHu9F6OANCc5vHZa 9TFblkuPapvq3KksHcK4xXp8Ika5PJ/wIugpOJl9NXIjdEq552UxncbiC g==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="331919419" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="331919419" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 08:29:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="802664317" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="802664317" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga005.jf.intel.com with ESMTP; 14 Oct 2022 08:29:43 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 08:29:43 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 08:29:42 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Fri, 14 Oct 2022 08:29:42 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Fri, 14 Oct 2022 08:29:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dTbfa9JaFzuY2Y2tGL4kN8t7LFVTzUzBF9fyQar62QxCXir+N+jY76uroghp5j7amT5YRWGX6HueXVtb/vIrt7gjy/R0ZKbbYrMMbeSFXHdvhsfrVvmPZ7qmZa2B9EK0bvlAONCzSKM7uExKtZlo4+erMwcKNeVQK9io2PpCXZQnfyc4vqcm63y2g2e8c7M28UBdMqJcxqIyWYl6I9AzqJ3O4Ja8FvZk/zReFu0H8qL7y488acIqpchQHNSGbU7bc7AvhXTs0nAE+uPh7mr8pCjTzXNptEdkU4ouLVRRtFNnr+x4VJSFzwNvP0ymbOb4whN1KDWpOtbtQKRjCxin5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TgHpKyl52b1Qr5KWu0T0OE9isylEiHX36J7C1sjjltg=; b=RL52N4NBl1h/VNgZ4YXc8uoDl7u/Q3BjnZPztLZzFWPq23b8tcyht+oeXkKq5FI6zz49DCuCCd0+bzD//XuNcRzWJx1RwtiwWtqnM8YAPtM/VbKG34KUdkinJbm0f1V/L83MzsPx9xLKhkWQswbtRq/9nGRvcuDJ5L4LRN/ABuE+K5+ajl4jftYz8Eedtf6i5Ukny+75XDYTzg9Vc0EtzwbAMGH266NcIzYEuK1O44GunBwE2i8kXy/Bj/yrz2rmZMzmlBrTLRNx7ne9kHbRcp2U+CheM+nLMf0NQK1kTWQd0k8xj75Ew5bGXoJJtDI97F2I3aPzVwd9/uKDsHCSSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) by MW4PR11MB7054.namprd11.prod.outlook.com (2603:10b6:303:219::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Fri, 14 Oct 2022 15:29:41 +0000 Received: from MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::5582:9796:3aaa:aa1]) by MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::5582:9796:3aaa:aa1%12]) with mapi id 15.20.5723.029; Fri, 14 Oct 2022 15:29:40 +0000 Date: Fri, 14 Oct 2022 16:29:34 +0100 From: Bruce Richardson To: Stephen Hemminger CC: "Power, Ciara" , David Marchand , Chengwen Feng , "thomas@monjalon.net" , "dev@dpdk.org" Subject: Re: [PATCH v2] usertools: telemetry json support pretty print Message-ID: References: <20221014023338.51464-1-fengchengwen@huawei.com> <20221014032504.32534-1-fengchengwen@huawei.com> <20221014080111.79c7c0bd@hermes.local> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20221014080111.79c7c0bd@hermes.local> X-ClientProxiedBy: LO2P265CA0178.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::22) To MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR11MB1629:EE_|MW4PR11MB7054:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cd55ec5-f6c3-4069-4bb7-08daadf8e955 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1wXhO9ZTZ9vMxT58zCadoN39LvqFXCPfmbtdO+RQexgjkdFJpFxUjripNob655TpTMx0CI0hreJYaZo+lu6zP+Z/ypJFg7e2kzEBTH4HEiRVc5XkJ2rZDYOaBaPr+GlF60SbrIbWqM5uhrbyJetfdBkt71zlF0E2gG1gYPkHejasMuJPRnyom2gp/GzR16qOrTZ46eQ/bDK42cRs3aP77RnW4ecJYmTvmmYhtaUuSuci0h7EHfA3fqfqo1RmhuEoe2W8M2kJJh2hrkSB1Mc6+Z5sE0PNBT5EMTx6j9aXzASldeHs6GL7Dx6C6EQ615hYRnmj9q2B8dsDMKkJdA/NbkyHk3TplHZYaQazcn3+0G6X1KARRiJxxlQiLtZN8tkaFm6R2eNRmFF8WYRwSX2osxGO9VWhZwKolUQQ9NwKSvTC5k51ycTTbZaGJBtXoe7pZU5fwiro6BQz8K7Inp/oB9y38rm0/DxGbcAzuspN5jBKz4CFGEmCVHY5Q3xL4NoACq8yVZj7LNqc+B8D2waS2RQBzCS3F2muEdpp/nPUorvVpCRC//DNN6f7dVllET2ovN/AMZVrsqItHdwb3hkEE98x3PGIldSjxGimzSxPMu6WqEMBegZ6zS25pC6adPZHzLb1Y0BPkh1ou1ec+4/9qZqozQ+BgsgQ2Hkv0GE9i6F1ynesIxQNNUqvSEasXCCCDgsxnBAl1IkS1Uohmh73Lg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1629.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199015)(2906002)(316002)(6486002)(54906003)(478600001)(6916009)(5660300002)(6512007)(66946007)(8676002)(8936002)(66556008)(41300700001)(6506007)(53546011)(6666004)(4326008)(66476007)(44832011)(186003)(26005)(82960400001)(38100700002)(83380400001)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?P0KRbQeRFXtOndruLt0kA+/Avb1pIpNflT6QDzk5Yu6LEolJCwQ171NDibP9?= =?us-ascii?Q?OAOSKcOl4goJdZe8QLK3aHfgwLBiBszjsRnOSxnQ1JTXn8hsu3wFQuhJQlfs?= =?us-ascii?Q?rpN+E3zhDa6SyC8c3eo/LmyGYS4OWzYQ9GqSQJxRzT+xUmgz/zSusRkfc6+N?= =?us-ascii?Q?92nWE5e7R9XLqjq+8XR+QCAH9tr27pwaUg2rJyS62coqwj9w62jqefo0uCDd?= =?us-ascii?Q?WJ8KolY0dv67v9pD/SKoeni2HhowWVwuinfS/WVZpbDv2v6hKGBpZEmWl4iA?= =?us-ascii?Q?hD2gC5gTcMaJosXzk0xl+n/HATrNixZhVCnZyevYmyPBAuy9PBU0GwYZl19K?= =?us-ascii?Q?ZZROWM8DFykmmoPmhpgeP8bjmwSCzibVGwj1geNbsvGTwZFcrCCF/xghbFJT?= =?us-ascii?Q?/06ccGx5A7I78K9araGCofME7Fa/WnUoFggKia7Pb9wKaBxiEK7lrJrIGEvk?= =?us-ascii?Q?9PWc9iOZl15uaD+PUMN8t6schbJFDcluKrjoyGb5QOAXgo3XHHEd25Qm493A?= =?us-ascii?Q?jxfvMYqSILBAtYaiqqIWFDpQqddiOlHMPbKcHD+fDS6TkRUCfTBZTInGApR2?= =?us-ascii?Q?fTud/Fa+VL/9D294/1kwXFFhDrfX50El60hI8Qi8itFAEyzwLpFMv9Vaueme?= =?us-ascii?Q?pQNr1C0X0TDlXcDKODr2BPhBHYUKHXohnhcZxF9gxeJRTYtuSJfDhCwZ+IBt?= =?us-ascii?Q?c7jOvYsPwzQoU6ufU5mczRAA9CXNSYEHTGeezJWhdRVisMT0YJelTHCJXJdm?= =?us-ascii?Q?vKGFYAiiICrQOXcmTzUmQxlbLd5FUz1azEw2z2I7YcH8O4dm1KPr6+cD2ngr?= =?us-ascii?Q?0jqUuqR7EbvWxII5LrOGCYucyf+2ejxeCcJCDPDuvJ1qkBrqCt7AfcsNSJHd?= =?us-ascii?Q?T/ZRFYPikNMean6TlFr5YgKYsElgOfgA99290hseHWlHco0M9swTzc8Ydhlx?= =?us-ascii?Q?zQT7Jday3TUjAEFsrjUUT0VZ26METc3ESyl8dRt0jOeqkJD1o2dMh4TGVuek?= =?us-ascii?Q?lXmeufVKH2M9+4JR2HLX0OXnluLbisn3jeuvjenL9LXjigqfHaw4B6Gw4y4q?= =?us-ascii?Q?/YTuBAMCUffHsyWpBLb4pZOfT5mrF4RvTR3+fOvxKNSTsmfMDUn5NtJPq3U5?= =?us-ascii?Q?hEjWzDElyXuz851cSHAREbFVXlaajs7YzMy3cttkvBtF/sPbkTgFVztDZEWe?= =?us-ascii?Q?Ml238YOHdkFErq9SkRLkXDiMlR5l48sV/n5xXhiXfgs8K5QDjeutGu0Ot9uU?= =?us-ascii?Q?oAr+kRo5KI7QQ3T835cGx7YyOc54qBOSvWCtAbNuvsa2yz3/iy048eMTRipg?= =?us-ascii?Q?tq3nb7Hcs73MdY40GSvQqd9gC4uHxRbMNm3bootAMPz7D8mW9UL3fbT+7/Uu?= =?us-ascii?Q?5sSs7mVGmkHuMvyNpsrVX3E93qpS8J6RPMYuXjbwCq5bVfCmuUr2ZV8eKsvw?= =?us-ascii?Q?89hG5c/o4lzxW43DHDDSTZWSTdxl7vObFCsspRi9kGGnvNl/XQwllR29RmTz?= =?us-ascii?Q?b644IFcAl3ut/k1h89SwW6/rVTMIlSwnMwoR50/VzWP+wIr/yjmiURePvCr6?= =?us-ascii?Q?rCWb9V+AvZSMINV+4g3z6GyyClmr2ECrrFcbTZtzvcEY0c9x5MB1ISTC8xsc?= =?us-ascii?Q?0pwu2m1LowDnFdrSv1yK4nQ=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 7cd55ec5-f6c3-4069-4bb7-08daadf8e955 X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1629.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 15:29:40.7022 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Tclc8s0m0AiVsAMq0hm9sSybuzAlLX3WYXLuxQjqtngM/Xa366pZra5BGGEJfh2JQClnm8q/n0wxMmVOUq1OROLppxyghtrAw/frtLdAgEM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB7054 X-OriginatorOrg: intel.com 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 On Fri, Oct 14, 2022 at 08:01:11AM -0700, Stephen Hemminger wrote: > On Fri, 14 Oct 2022 14:02:10 +0100 > Bruce Richardson wrote: > > > On Fri, Oct 14, 2022 at 12:44:33PM +0000, Power, Ciara wrote: > > > Hi Chengwen, > > > > > > > -----Original Message----- > > > > From: David Marchand > > > > Sent: Friday 14 October 2022 10:50 > > > > To: Chengwen Feng > > > > Cc: thomas@monjalon.net; dev@dpdk.org; Power, Ciara > > > > > > > > Subject: Re: [PATCH v2] usertools: telemetry json support pretty print > > > > > > > > On Fri, Oct 14, 2022 at 5:31 AM Chengwen Feng > > > > wrote: > > > > > > > > > > Currently, the dpdk-telemetry.py show json in raw format, which is not > > > > > good for human reading. > > > > > > > > > > E.g. The command '/ethdev/xstats,0' will output: > > > > > {"/ethdev/xstats": {"rx_good_packets": 0, "tx_good_packets": 0, > > > > > "rx_good_bytes": 0, "tx_good_bytes": 0, "rx_missed_errors": 0, > > > > > "rx_errors": 0, "tx_errors": 0, "rx_mbuf_allocation_errors": 0, > > > > > "rx_q0_packets": 0,...}} > > > > > > > > > > This patch supports json pretty print by adding extra indent=4 > > > > > parameter, so the same command will output: > > > > > { > > > > > "/ethdev/xstats": { > > > > > "rx_good_packets": 0, > > > > > "tx_good_packets": 0, > > > > > "rx_good_bytes": 0, > > > > > "tx_good_bytes": 0, > > > > > "rx_missed_errors": 0, > > > > > "rx_errors": 0, > > > > > "tx_errors": 0, > > > > > "rx_mbuf_allocation_errors": 0, > > > > > "rx_q0_packets": 0, > > > > > ... > > > > > } > > > > > } > > > > > > > > > > Signed-off-by: Chengwen Feng > > > > > > > > It's indeed easier to read, but maybe 4 chars is too much. > > > > 2 chars seem enough to me. > > > [CP] > > > +1 on using 2 chars > > > > > > > > > > > In any case I like the idea: > > > > I like it too, for interactive use. However, we also have some hooks in the > > code for when the app is being run non-interactively i.e. from a script. In > > that case, we probably want the indent to be unused. > > > > The function "handle_socket()" tracks if the output is a tty via the "prompt" > > variable. That could be passed through to the "read_socket()" call to > > optionally not-indent the output. > > > > /Bruce > > Convention in other tools is a -p flag for "pretty output" Since we already support detecting interactive use, I think having the pretty output by default in that case is probably good. For non-interactive use a -p flag might make sense, but even then I'm not sure it's hugely worthwhile. /Bruce