Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/vmstat Don't print "nan" when there is no disk activ...



details:   https://anonhg.NetBSD.org/src/rev/fd3450bb9027
branches:  trunk
changeset: 356147:fd3450bb9027
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Sep 06 06:05:23 2017 +0000

description:
Don't print "nan" when there is no disk activity.

diffstat:

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

diffs (32 lines):

diff -r 9a7d2d4f75c9 -r fd3450bb9027 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c   Wed Sep 06 03:10:09 2017 +0000
+++ b/usr.bin/vmstat/vmstat.c   Wed Sep 06 06:05:23 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.217 2017/07/04 21:19:33 mlelstv Exp $ */
+/* $NetBSD: vmstat.c,v 1.218 2017/09/06 06:05:23 mlelstv 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.217 2017/07/04 21:19:33 mlelstv Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.218 2017/09/06 06:05:23 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -1123,8 +1123,11 @@
 
        for (dn = 0; dn < ndrive; ++dn) {
                /* elapsed time for disk stats */
-               dtime = (double)cur.timestamp[dn].tv_sec +
-                       ((double)cur.timestamp[dn].tv_usec / (double)1000000);
+               dtime = cur.cp_etime;
+               if (cur.timestamp[dn].tv_sec || cur.timestamp[dn].tv_usec) {
+                       dtime = (double)cur.timestamp[dn].tv_sec +
+                               ((double)cur.timestamp[dn].tv_usec / (double)1000000);
+               }
 
                if (!drv_select[dn])
                        continue;



Home | Main Index | Thread Index | Old Index