summaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2019-05-08 23:54:14 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2019-05-08 23:54:14 +0000
commit17c17ef93a7c767f4865860180819b575215523d (patch)
treeec6cf60ce261b4d49053f7e31c306f4224945e31 /usr.bin/systat
parent21edb7d3f0a0ed4a5ae7e77b134af4b2f7410b2e (diff)
allow switching to print stats since boot via 'b'.
ok beck deraadt
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/iostat.c43
-rw-r--r--usr.bin/systat/systat.111
2 files changed, 45 insertions, 9 deletions
diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c
index ae32ff09eff..e3cb3d927cd 100644
--- a/usr.bin/systat/iostat.c
+++ b/usr.bin/systat/iostat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iostat.c,v 1.47 2017/04/16 14:24:03 beck Exp $ */
+/* $OpenBSD: iostat.c,v 1.48 2019/05/08 23:54:13 tedu Exp $ */
/* $NetBSD: iostat.c,v 1.5 1996/05/10 23:16:35 thorpej Exp $ */
/*
@@ -43,8 +43,8 @@
#include "systat.h"
#include "dkstats.h"
-extern struct _disk cur, last;
-struct bcachestats bclast, bccur;
+extern struct _disk cur, last;
+struct bcachestats bclast, bccur;
static double etime;
@@ -87,11 +87,28 @@ field_def *view_io_0[] = {
FLD_IO_WTPS, FLD_IO_SEC, FLD_IO_SVAL, FLD_IO_SSTR, NULL
};
+static enum state { BOOT, TIME } state = TIME;
+
+static int
+io_keyboard_callback(int ch)
+{
+ switch (ch) {
+ case 'b':
+ state = BOOT;
+ break;
+ case 't':
+ state = TIME;
+ break;
+ default:
+ return keyboard_callback(ch);
+ }
+ return 0;
+}
/* Define view managers */
struct view_manager iostat_mgr = {
"Iostat", select_io, read_io, NULL, print_header,
- print_io, keyboard_callback, NULL, NULL
+ print_io, io_keyboard_callback, NULL, NULL
};
@@ -115,6 +132,15 @@ read_io(void)
size_t size;
dkreadstats();
+ if (state == BOOT) {
+ unsigned int dn;
+ for (dn = 0; dn < last.dk_ndrive; dn++) {
+ last.dk_rbytes[dn] = 0;
+ last.dk_wbytes[dn] = 0;
+ last.dk_rxfer[dn] = 0;
+ last.dk_wxfer[dn] = 0;
+ }
+ }
dkswap();
num_disp = cur.dk_ndrive + 1;
@@ -130,6 +156,9 @@ read_io(void)
if (bclast.numbufs == 0)
bclast = bccur;
+ if (state == BOOT)
+ memset(&bclast, 0, sizeof(bclast));
+
return 0;
}
@@ -173,7 +202,7 @@ initiostat(void)
for (v = views_io; v->name != NULL; v++)
add_view(v);
- return(1);
+ return (1);
}
void
@@ -206,8 +235,8 @@ void
showdrive(int dn)
{
print_fld_str(FLD_IO_DEVICE, cur.dk_name[dn]);
- print_fld_size(FLD_IO_READ, cur.dk_rbytes[dn]/etime);
- print_fld_size(FLD_IO_WRITE, cur.dk_wbytes[dn]/ etime);
+ print_fld_size(FLD_IO_READ, cur.dk_rbytes[dn] / etime);
+ print_fld_size(FLD_IO_WRITE, cur.dk_wbytes[dn] / etime);
print_fld_size(FLD_IO_RTPS, cur.dk_rxfer[dn] / etime);
print_fld_size(FLD_IO_WTPS, cur.dk_wxfer[dn] / etime);
print_fld_float(FLD_IO_SEC, ATIME(cur.dk_time, dn) / etime, 1);
diff --git a/usr.bin/systat/systat.1 b/usr.bin/systat/systat.1
index c46f5aeb8b4..4316e7cd943 100644
--- a/usr.bin/systat/systat.1
+++ b/usr.bin/systat/systat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: systat.1,v 1.111 2019/03/04 21:27:35 dlg Exp $
+.\" $OpenBSD: systat.1,v 1.112 2019/05/08 23:54:13 tedu Exp $
.\" $NetBSD: systat.1,v 1.6 1996/05/10 23:16:39 thorpej Exp $
.\"
.\" Copyright (c) 1985, 1990, 1993
@@ -30,7 +30,7 @@
.\"
.\" @(#)systat.1 8.2 (Berkeley) 12/30/93
.\"
-.Dd $Mdocdate: March 4 2019 $
+.Dd $Mdocdate: May 8 2019 $
.Dt SYSTAT 1
.Os
.Sh NAME
@@ -303,6 +303,13 @@ Statistics
on disk throughput show, for each drive, data transferred in bytes,
number of disk transactions performed, and time spent in disk accesses
(in fractions of a second).
+Pressing
+.Ic b
+displays statistics as calculated from boot time.
+.Ic t
+changes the counters to show the average per second over
+the display refresh interval;
+this is the default.
.It Ic malloc
Display kernel
.Xr malloc 9