From owner-svn-src-all@freebsd.org Wed Sep 9 08:40:18 2015 Return-Path: Delivered-To: svn-src-all@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 ACDFBA0004B; Wed, 9 Sep 2015 08:40:18 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 9D6111163; Wed, 9 Sep 2015 08:40:18 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t898eIG9079708; Wed, 9 Sep 2015 08:40:18 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t898eILL079707; Wed, 9 Sep 2015 08:40:18 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201509090840.t898eILL079707@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 9 Sep 2015 08:40:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287593 - stable/10/usr.bin/netstat X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 08:40:18 -0000 Author: hrs Date: Wed Sep 9 08:40:17 2015 New Revision: 287593 URL: https://svnweb.freebsd.org/changeset/base/287593 Log: MFC r287406: Divide statistics in the number of packets with 1000 instead of 1024 in human-readable form. PR: 183598 Modified: stable/10/usr.bin/netstat/if.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/netstat/if.c ============================================================================== --- stable/10/usr.bin/netstat/if.c Wed Sep 9 07:04:00 2015 (r287592) +++ stable/10/usr.bin/netstat/if.c Wed Sep 9 08:40:17 2015 (r287593) @@ -165,7 +165,8 @@ pfsync_stats(u_long off, const char *nam * Display a formatted value, or a '-' in the same space. */ static void -show_stat(const char *fmt, int width, u_long value, short showvalue) +show_stat(const char *fmt, int width, u_long value, short showvalue, + int div1000) { const char *lsep, *rsep; char newfmt[32]; @@ -192,7 +193,8 @@ show_stat(const char *fmt, int width, u_ /* Format in human readable form. */ humanize_number(buf, sizeof(buf), (int64_t)value, "", - HN_AUTOSCALE, HN_NOSPACE | HN_DECIMAL); + HN_AUTOSCALE, HN_NOSPACE | HN_DECIMAL | \ + ((div1000) ? HN_DIVISOR_1000 : 0)); sprintf(newfmt, "%s%%%ds%s", lsep, width, rsep); printf(newfmt, buf); } else { @@ -287,7 +289,7 @@ intpr(int interval, void (*pfunc)(char * printf("%-5.5s", ifa->ifa_name); #define IFA_MTU(ifa) (((struct if_data *)(ifa)->ifa_data)->ifi_mtu) - show_stat("lu", 6, IFA_MTU(ifa), IFA_MTU(ifa)); + show_stat("lu", 6, IFA_MTU(ifa), IFA_MTU(ifa), 0); #undef IFA_MTU switch (ifa->ifa_addr->sa_family) { @@ -373,18 +375,18 @@ intpr(int interval, void (*pfunc)(char * } #define IFA_STAT(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s) - show_stat("lu", 8, IFA_STAT(ipackets), link|network); - show_stat("lu", 5, IFA_STAT(ierrors), link); - show_stat("lu", 5, IFA_STAT(iqdrops), link); + show_stat("lu", 8, IFA_STAT(ipackets), link|network, 1); + show_stat("lu", 5, IFA_STAT(ierrors), link, 1); + show_stat("lu", 5, IFA_STAT(iqdrops), link, 1); if (bflag) - show_stat("lu", 10, IFA_STAT(ibytes), link|network); - show_stat("lu", 8, IFA_STAT(opackets), link|network); - show_stat("lu", 5, IFA_STAT(oerrors), link); + show_stat("lu", 10, IFA_STAT(ibytes), link|network, 0); + show_stat("lu", 8, IFA_STAT(opackets), link|network, 1); + show_stat("lu", 5, IFA_STAT(oerrors), link, 1); if (bflag) - show_stat("lu", 10, IFA_STAT(obytes), link|network); - show_stat("NRSlu", 5, IFA_STAT(collisions), link); + show_stat("lu", 10, IFA_STAT(obytes), link|network, 0); + show_stat("NRSlu", 5, IFA_STAT(collisions), link, 1); if (dflag) - show_stat("LSlu", 5, IFA_STAT(oqdrops), link); + show_stat("LSlu", 5, IFA_STAT(oqdrops), link, 1); putchar('\n'); if (!aflag) @@ -569,16 +571,16 @@ loop: fill_iftot(new); - show_stat("lu", 10, new->ift_ip - old->ift_ip, 1); - show_stat("lu", 5, new->ift_ie - old->ift_ie, 1); - show_stat("lu", 5, new->ift_id - old->ift_id, 1); - show_stat("lu", 10, new->ift_ib - old->ift_ib, 1); - show_stat("lu", 10, new->ift_op - old->ift_op, 1); - show_stat("lu", 5, new->ift_oe - old->ift_oe, 1); - show_stat("lu", 10, new->ift_ob - old->ift_ob, 1); - show_stat("NRSlu", 5, new->ift_co - old->ift_co, 1); + show_stat("lu", 10, new->ift_ip - old->ift_ip, 1, 1); + show_stat("lu", 5, new->ift_ie - old->ift_ie, 1, 1); + show_stat("lu", 5, new->ift_id - old->ift_id, 1, 1); + show_stat("lu", 10, new->ift_ib - old->ift_ib, 1, 0); + show_stat("lu", 10, new->ift_op - old->ift_op, 1, 1); + show_stat("lu", 5, new->ift_oe - old->ift_oe, 1, 1); + show_stat("lu", 10, new->ift_ob - old->ift_ob, 1, 0); + show_stat("NRSlu", 5, new->ift_co - old->ift_co, 1, 1); if (dflag) - show_stat("LSlu", 5, new->ift_od - old->ift_od, 1); + show_stat("LSlu", 5, new->ift_od - old->ift_od, 1, 1); putchar('\n'); fflush(stdout);