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 3FB5CA00C2; Fri, 14 Oct 2022 04:39:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 317CB4014F; Fri, 14 Oct 2022 04:39:25 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 52D3E400D4 for ; Fri, 14 Oct 2022 04:39:23 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MpVph28w6zVhyw; Fri, 14 Oct 2022 10:34:52 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) 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 10:39:21 +0800 From: Chengwen Feng To: CC: , Subject: [PATCH] usertools: telemetry json support pretty print Date: Fri, 14 Oct 2022 02:33:38 +0000 Message-ID: <20221014023338.51464-1-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected 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 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 outupt: {"/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 --- usertools/dpdk-telemetry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py index a81868a547..315f78fb8f 100755 --- a/usertools/dpdk-telemetry.py +++ b/usertools/dpdk-telemetry.py @@ -33,7 +33,7 @@ def read_socket(sock, buf_len, echo=True): sock.close() raise if echo: - print(json.dumps(ret)) + print(json.dumps(ret, indent=4)) return ret -- 2.17.1