From owner-svn-src-stable@freebsd.org Fri Mar 10 06:17:55 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8ED5D05CC7; Fri, 10 Mar 2017 06:17:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7DEC519F7; Fri, 10 Mar 2017 06:17:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2A6HsCB083117; Fri, 10 Mar 2017 06:17:54 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2A6HsgC083116; Fri, 10 Mar 2017 06:17:54 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703100617.v2A6HsgC083116@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Mar 2017 06:17:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r314991 - stable/11/usr.bin/ctlstat X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Mar 2017 06:17:55 -0000 Author: mav Date: Fri Mar 10 06:17:54 2017 New Revision: 314991 URL: https://svnweb.freebsd.org/changeset/base/314991 Log: MFC r314592: Fix JSON output. Modified: stable/11/usr.bin/ctlstat/ctlstat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/ctlstat/ctlstat.c ============================================================================== --- stable/11/usr.bin/ctlstat/ctlstat.c Fri Mar 10 05:44:14 2017 (r314990) +++ stable/11/usr.bin/ctlstat/ctlstat.c Fri Mar 10 06:17:54 2017 (r314991) @@ -312,8 +312,8 @@ compute_stats(struct ctl_io_stats *cur_s * conducive to programming, however. */ -#define PRINT_BINTIME(prefix, bt) \ - printf("%s %jd.%06ju\n", prefix, (intmax_t)(bt).sec, \ +#define PRINT_BINTIME(bt) \ + printf("%jd.%06ju", (intmax_t)(bt).sec, \ (uintmax_t)(((bt).frac >> 32) * 1000000 >> 32)) static const char *iotypes[] = {"NO IO", "READ", "WRITE"}; @@ -335,15 +335,15 @@ ctlstat_dump(struct ctlstat_context *ctx stats[i].operations[iotype]); printf(" dmas %ju\n", (uintmax_t) stats[i].dmas[iotype]); - PRINT_BINTIME(" io time", stats[i].time[iotype]); - PRINT_BINTIME(" dma time", stats[i].dma_time[iotype]); + printf(" io time "); + PRINT_BINTIME(stats[i].time[iotype]); + printf("\n dma time "); + PRINT_BINTIME(stats[i].dma_time[iotype]); + printf("\n"); } } } -#define JSON_BINTIME(prefix, bt) \ - printf("\"%s\":%jd.%06ju,", prefix, (intmax_t)(bt).sec, \ - (uintmax_t)(((bt).frac >> 32) * 1000000 >> 32)) static void ctlstat_json(struct ctlstat_context *ctx) { int iotype, i; @@ -357,14 +357,17 @@ ctlstat_json(struct ctlstat_context *ctx stats[i].item); for (iotype = 0; iotype < CTL_STATS_NUM_TYPES; iotype++) { printf("{\"type\":\"%s\",", iotypes[iotype]); - printf("\"bytes\":%ju,", (uintmax_t)stats[ - i].bytes[iotype]); - printf("\"operations\":%ju,", (uintmax_t)stats[ - i].operations[iotype]); - printf("\"dmas\":%ju}", (uintmax_t) + printf("\"bytes\":%ju,", (uintmax_t) + stats[i].bytes[iotype]); + printf("\"operations\":%ju,", (uintmax_t) + stats[i].operations[iotype]); + printf("\"dmas\":%ju,", (uintmax_t) stats[i].dmas[iotype]); - JSON_BINTIME("io time", stats[i].time[iotype]); - JSON_BINTIME("dma time", stats[i].dma_time[iotype]); + printf("\"io time\":"); + PRINT_BINTIME(stats[i].time[iotype]); + printf(",\"dma time\":"); + PRINT_BINTIME(stats[i].dma_time[iotype]); + printf("}"); if (iotype < (CTL_STATS_NUM_TYPES - 1)) printf(","); /* continue io array */ }