Date: Wed, 9 Sep 2015 08:40:18 +0000 (UTC) From: Hiroki Sato <hrs@FreeBSD.org> 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 Message-ID: <201509090840.t898eILL079707@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509090840.t898eILL079707>