Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/vmstat Fix header, format and total count of system ...



details:   https://anonhg.NetBSD.org/src/rev/d28da5ebf48f
branches:  trunk
changeset: 762128:d28da5ebf48f
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Wed Feb 16 12:58:38 2011 +0000

description:
Fix header, format and total count of system interrupt counters.

diffstat:

 usr.bin/vmstat/vmstat.c |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (70 lines):

diff -r b7b2ba20a554 -r d28da5ebf48f usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c   Wed Feb 16 10:13:00 2011 +0000
+++ b/usr.bin/vmstat/vmstat.c   Wed Feb 16 12:58:38 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.179 2011/02/05 13:12:07 mlelstv Exp $ */
+/* $NetBSD: vmstat.c,v 1.180 2011/02/16 12:58:38 nakayama Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.179 2011/02/05 13:12:07 mlelstv Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.180 2011/02/16 12:58:38 nakayama Exp $");
 #endif
 #endif /* not lint */
 
@@ -1137,7 +1137,9 @@
 
        counttotal = 0;
        uptime = getuptime();
-       (void)printf("%-34s %16s %8s %s\n", "event", "total", "rate", "type");
+       if (type == EVCNT_TYPE_ANY)
+               (void)printf("%-34s %16s %8s %s\n", "event", "total", "rate",
+                   "type");
 
        if (memf == NULL) do {
                const int mib[4] = { CTL_KERN, KERN_EVCNT, type,
@@ -1175,7 +1177,9 @@
                while (evs < last_evs
                    && buflen >= sizeof(*evs)/sizeof(uint64_t)
                    && buflen >= evs->ev_len) {
-                       (void)printf("%s %s%*s %16"PRIu64" %8"PRIu64" %s\n",
+                       (void)printf(type == EVCNT_TYPE_ANY ?
+                           "%s %s%*s %16"PRIu64" %8"PRIu64" %s\n" :
+                           "%s %s%*s %16"PRIu64" %8"PRIu64"\n",
                            evs->ev_strings,
                            evs->ev_strings + evs->ev_grouplen + 1,
                            34 - (evs->ev_grouplen + 1 + evs->ev_namelen), "",
@@ -1184,8 +1188,8 @@
                            (evs->ev_type < __arraycount(evtypes) ?
                                evtypes[evs->ev_type] : "?"));
                        buflen -= evs->ev_len;
+                       counttotal += evs->ev_count;
                        evs = (const void *)((const uint64_t *)evs + evs->ev_len);
-                       counttotal += evcnt.ev_count++;
                }
                free(buf);
                if (type != EVCNT_TYPE_ANY)
@@ -1211,7 +1215,9 @@
                deref_kptr(evcnt.ev_name, evname,
                    (size_t)evcnt.ev_namelen + 1, "event chain trashed");
 
-               (void)printf("%s %s%*s %16"PRIu64" %8"PRIu64" %s\n",
+               (void)printf(type == EVCNT_TYPE_ANY ?
+                   "%s %s%*s %16"PRIu64" %8"PRIu64" %s\n" :
+                   "%s %s%*s %16"PRIu64" %8"PRIu64"\n",
                    evgroup, evname,
                    34 - (evcnt.ev_grouplen + 1 + evcnt.ev_namelen), "",
                    evcnt.ev_count,
@@ -1219,7 +1225,7 @@
                    (evcnt.ev_type < __arraycount(evtypes) ?
                        evtypes[evcnt.ev_type] : "?"));
 
-               counttotal += evcnt.ev_count++;
+               counttotal += evcnt.ev_count;
        }
        if (type != EVCNT_TYPE_ANY)
                (void)printf("%-34s %16"PRIu64" %8"PRIu64"\n",



Home | Main Index | Thread Index | Old Index