Module Name: src Committed By: skrll Date: Sun Feb 16 09:44:59 UTC 2025
Modified Files: src/usr.bin/vmstat: vmstat.c Log Message: When printing interrupt statistics line up wrt the totals. To generate a diff of this commit: cvs rdiff -u -r1.258 -r1.259 src/usr.bin/vmstat/vmstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/vmstat/vmstat.c diff -u src/usr.bin/vmstat/vmstat.c:1.258 src/usr.bin/vmstat/vmstat.c:1.259 --- src/usr.bin/vmstat/vmstat.c:1.258 Sat Sep 9 20:13:54 2023 +++ src/usr.bin/vmstat/vmstat.c Sun Feb 16 09:44:59 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: vmstat.c,v 1.258 2023/09/09 20:13:54 ad Exp $ */ +/* $NetBSD: vmstat.c,v 1.259 2025/02/16 09:44:59 skrll Exp $ */ /*- * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020 @@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95"; #else -__RCSID("$NetBSD: vmstat.c,v 1.258 2023/09/09 20:13:54 ad Exp $"); +__RCSID("$NetBSD: vmstat.c,v 1.259 2025/02/16 09:44:59 skrll Exp $"); #endif #endif /* not lint */ @@ -1357,9 +1357,24 @@ doevcnt(int verbose, int type) if (rate_max < len) rate_max = len; buflen -= evs->ev_len; + counttotal += evs->ev_count; evs = (const void *) ((const uint64_t *)evs + evs->ev_len); } + if (type != EVCNT_TYPE_ANY) { + char cbuf[64]; + size_t len; + + len = snprintf(cbuf, sizeof(cbuf), "%"PRIu64, + counttotal); + if (total_max < len) + total_max = len; + + len = snprintf(cbuf, sizeof(cbuf), "%"PRIu64, + counttotal / uptime); + if (rate_max < len) + rate_max = len; + } (void)printf(type == EVCNT_TYPE_ANY ? "%-*s %*s %*s %s\n" : @@ -1388,7 +1403,6 @@ doevcnt(int verbose, int type) (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); }