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 D9EE7A00C2; Fri, 14 Oct 2022 17:01:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 828A842D89; Fri, 14 Oct 2022 17:01:16 +0200 (CEST) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mails.dpdk.org (Postfix) with ESMTP id D296A42C6E for ; Fri, 14 Oct 2022 17:01:15 +0200 (CEST) Received: by mail-pl1-f174.google.com with SMTP id z20so4956545plb.10 for ; Fri, 14 Oct 2022 08:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=e9XNfjPFv2RHK4Po4aTlcops9+V6R9SymsHlfz2BIsE=; b=Dv/il94uejL2Iy5RdOGdAefsCr/hbuLInDkupUwi10S9gP6JcPMLUTsGfg+rS36WLZ ZOIK6EWv6J0kXC7D/yDQeaesL0vejqqLW7hrouw297sCmo2oY0ImD4u+JBesiOKwD/SX hzRGbf7Nz4rqhVLEjOCfBCdcqqjsY2iYLS4rFftQYhBNWYq9FUfHajG+mMbunefDxkW1 r+4fHXi/h7sh9OKi0/ETh1s3+SMdqpvAHXe+DAbaMhQpSN/S/urLee7gg4BUE9ipW701 TxlYdTVyVn+fLT6Ftv8UsMGYDZw9P70CPRZZ5KojmWSBF2HkdE6J6aywbp0d5hZ4L27F hm8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e9XNfjPFv2RHK4Po4aTlcops9+V6R9SymsHlfz2BIsE=; b=onMDNhlTAdgj+4w8JNFlvjWP5z5QV5J2h9kox3GtLKySdqzF7Q1qfOxEAzvkjCqJ5S q798AK9dO4wRDxGAxmHAig5aANCYsGBiOsOaaq3zuwbjUq7j2rtxLPLAVKaUiuauUVse CiY0EazoRpTd3p39Yrdc8V747xZQKTGXk7G3rrWmschcLmdZOvhMD2xwHy53u0xbXRwX zCuGioLbzUr8fuqDN4itrED4mGvhylBgfmyzqkhOYnGV/J5zEMbmDc4cwcvQM9uE2vAA Bjf1PFhOxpWBxUMvxJKi3Su7u2yssk0MDqtY6kS1Kd447IXAnfD3Ymc7zXNR3/X0odNU UUjg== X-Gm-Message-State: ACrzQf0ugqJ/lNBJDYfwMEk/W1CfZ63KDWSEGdtCq/761cPM9iK/awMx KPjb+sTNa+lc5pFrP1IrwIlWCQ== X-Google-Smtp-Source: AMsMyM4+EczIMwxywcUw8csJeNVYTzbUqDn5naFJ7C2oeYXIrAGn7yaWNxyNTlZ0pD5+SuIoGCYTuw== X-Received: by 2002:a17:90b:691:b0:20d:6171:c94 with SMTP id m17-20020a17090b069100b0020d61710c94mr17277490pjz.25.1665759674795; Fri, 14 Oct 2022 08:01:14 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id 7-20020a620407000000b0056283e2bdbdsm1859223pfe.138.2022.10.14.08.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 08:01:14 -0700 (PDT) Date: Fri, 14 Oct 2022 08:01:11 -0700 From: Stephen Hemminger To: Bruce Richardson 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: <20221014080111.79c7c0bd@hermes.local> In-Reply-To: References: <20221014023338.51464-1-fengchengwen@huawei.com> <20221014032504.32534-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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, 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"