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 9227FA00C2; Fri, 14 Oct 2022 15:02:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B9FB942D89; Fri, 14 Oct 2022 15:02:25 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id CFB8342C6E for ; Fri, 14 Oct 2022 15:02:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665752544; x=1697288544; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=lGfOmyMktkE3q12Rv8X02IoHKHKNRuKHB67cVBVZXDk=; b=RCgcNnXc3vA1e1TNS8NVkrIxrdysIiRdliGbJGG4xl8qAnnz7gZSz7iG uu1n6srnw5ICLWcddxuZMnVzGCGq4O2wDHpYrPHlP50uP9TXiAE/6e2x4 xXbWC1G9EEmX4P1rHGcMHmB7ln0IZv6YjgY9WUckRsJq3HFE5DrOC5tii UV9f5K5qNIoEe3Uuayc/gz7dL206acFt2oUG/+QhZFUBdTOLlA04OSgTa 4xgX/3BMQ2DBUYP+lCGFptaCttY0p0uv17Sl4m8hiALVNWnfpJZohgJCr b8Hd6CHrxK3ajzCjPjn4IbhGhUigxkQyfX7M5t8lxKwL5sH5khIvZRnRM w==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="285757931" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="285757931" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 06:02:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="622527362" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="622527362" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga007.jf.intel.com with ESMTP; 14 Oct 2022 06:02:21 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) 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 06:02:21 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx611.amr.corp.intel.com (10.18.126.91) 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 06:02:20 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) 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 06:02:20 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.175) by edgegateway.intel.com (192.55.55.68) 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 06:02:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oehg1yDx6kFxoNpj2145GFFFr3VGzDdpD0rgICbK1mV+weVkDFgHMukoe1AnNI0GcwPvpfrZFuhbB9hUVafzAvb8uaL7L8zZyAsd7HbtcQgDG6LRAqXL45Mgxll7QNErMFDpm96gaR/Uuun4Fby5VypBA1gjbR1+R2WWH4jMBEIbVthGTv2rTJXK3SuIZPvpI03MrCshbB8926yZQZMsHWXkA4zN2uassWV9ynUZ5FSy4ovqTqnJNSeoXh4fU0P4IwNKGzNASoI5zXrSzx7ySc+LGEYwITUrDB+mTJh2KZY0anz3+e+CqPp/wLo7Oh4jsUz3iOlhNueOQqfZySqWbw== 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=hNLqLqf4ePK1Sg/VKrILXGX2zwcwEl0LnU2RgkCDFBs=; b=D0XzDFltt4oAMLYla/Bcv+hUmHPkXF+tph6id3c8cKTncmpg5TcH28f84WsjeDpQg72jSu5HMGcVJaKVJyJGBLq8R43OvOvEcTZ2f94qvM0xpCcjrCC+PX5lL9XhaZ18/KMbA1HaUmYIFDmuWy30mdrax+UfUrC1KRhnl0+dT3Q27jeTq+onmYG+34KhzVgiMyeVZz6kfs/vDMSLudhcCfET1FjBcL/c+Mlk7zR7dzSoYwDDKVdcnBUncB+Bh4c57ZyYIHOpTmo4iG5hgaKn+/tPrBounqe0QigNY8BxtJTlPRqbaPGnaIHiINM7N9WMpc5s5vxvvsRYsGF1q4RKlw== 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 PH7PR11MB6745.namprd11.prod.outlook.com (2603:10b6:510:1af::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Fri, 14 Oct 2022 13:02:16 +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 13:02:16 +0000 Date: Fri, 14 Oct 2022 14:02:10 +0100 From: Bruce Richardson To: "Power, Ciara" CC: 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> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO4P265CA0018.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ad::11) To MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR11MB1629:EE_|PH7PR11MB6745:EE_ X-MS-Office365-Filtering-Correlation-Id: 982ecaed-e00d-44e6-be35-08daade45191 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IJn6tgxlFixxuoQ/Zq6Np8CCc+4DgQ2OYNsdkVFn4cj0ZRLRPx9aUahPGRPpK/VL+qC/6RJsVPL5zZ1zkxxMOJnVGeO0WThgkWrDdmjZkDaZ2xMGsigIhXQq+3umbvx+pEG+JxMVgYnVvlxS2p5EuJMd6A1kw1HXdXtFwRUDN9eXvNS1mj0gNYbtbGHqkyfLrK2P0RI4UcLTemUTx9XNTMj3jdo7Ev5zZ5Z0Xbqv/99/vpOzCFiURu+PbzsmJomLF90Absv9SXBCVfDq0whxoHS3KWTi94p7cISvdiAowz+JRWC8RuxO2iXdQNdOubssjkZTODjSKbybk/ChM9z+qZHvD1rWoPu0fVe18/kp+qjsjOUdaJirVD8qCOlc3fTELX24IymfQgSWb/SSZAZcsBwRODSkXaO7hQJy49W7jSWnDB5QqzMznSLul33kE0kofdq5Q/ayDaUDSS/BZrWwtL2kP+zqIkU+WWGojI67JV3ydRELAk3KgjjzHRyhUGGK2EyaH7q4qIpWHcHel51bTGIiiiHhrCOtHiCvN3SecVNqTFsLzBkPIZ0g3Z82DDsKyhCF6gMf5/TTId/lWep7NW8ThkzB+w2xKGolsyh40m6AvwAhKMHiDeFzG6Sp55ismdQs+O5TXpcTMtU9RgRhLzN/ziZiXiy+EPVyIvW6ZGZPNITK5+hUia3Xi/xiopI4xcIiPgO6F8TcXjBOg8pgAA== 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)(366004)(396003)(376002)(346002)(39860400002)(136003)(451199015)(186003)(478600001)(6486002)(4326008)(316002)(66476007)(8676002)(66556008)(66946007)(38100700002)(26005)(6666004)(6512007)(53546011)(6636002)(6506007)(54906003)(86362001)(83380400001)(44832011)(8936002)(82960400001)(41300700001)(6862004)(5660300002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4Qs5UnJtDGQUewxwTAltcS0ZgvYDjS4AEaqwU8DxWbo3Io+akUgExWcnhhGx?= =?us-ascii?Q?TtBMflPfdOFZMkv3QV25daizcKS+Sett0APsOufJ4/kTLmzcOKR+X3+cxFgM?= =?us-ascii?Q?mOh5E+9rTmwDx+zcP3YU6TFYUUEO5fcbSQAYzkDRoicrKwYcArICHGUV+IKF?= =?us-ascii?Q?8wBIvtwNof7QMQV3SBRh/m0muC/TgeSbCTjoGzPvI8jsXG11bWoFu5K4W8XF?= =?us-ascii?Q?pEqQus1Lbj0GzDhOc/8zXMCW0zO97yxkX/sfZQnHAqPIlT1xh5Dpe9Axbv/1?= =?us-ascii?Q?t15TBUbslsz5XPdocIo+Go19Eri7aE607HHYR7xuSgNJNLrfIVYNCMUNsxNx?= =?us-ascii?Q?0JjAdurK16TVD8Yxv2RNTOs9Duji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ascii?Q?5SokesQz4EDJvEqHUvPfLeq5B5Z0rShbv94a/9SOqSqWxizL0EmL6xA7l/te?= =?us-ascii?Q?A2T2GVtYR9Egp6nHXoZ0StQHj2p9CM8IkzkIPN+RD0C2y5Bg9CZemHP10D+b?= =?us-ascii?Q?vnExW9+yCs42Jew7rrVT+z2/jDFQWQ0uFfsOIjimZK87HW1wxq6UurhBXUKJ?= =?us-ascii?Q?i1gmQ4nQRelzDkL+BG0y+wHy+XrJ5EBEefXdM8y497Jm7DFq8y+CHnYrC9DQ?= =?us-ascii?Q?8LpVHtPhrQ0yX2QO9kbyhzJbS7+IcgLa/oZCNSRbP92JCajQ9YXPBkMfmP1r?= =?us-ascii?Q?33ayB1AIwXeveOX1paEmqMyGY9uFuIisZyv3pR5H1+f6TDsOximQdaBHTPvD?= =?us-ascii?Q?zDuEDKV2CYTfWV5sZL4gZ9U=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 982ecaed-e00d-44e6-be35-08daade45191 X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1629.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 13:02:16.1813 (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: wl9th/XVC+i27q6Vlikt91tnfrHdu2XNtsx7oguPTHxnAykLC5mqnkCIpn4CgGXgGND0LibWw4sM5ZCB0GoB4Hb8qAeMhZyxP0ol8uplMaY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6745 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 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