diff options
author | claudio <claudio@openbsd.org> | 2014-04-21 20:20:37 +0000 |
---|---|---|
committer | claudio <claudio@openbsd.org> | 2014-04-21 20:20:37 +0000 |
commit | 2fe39d326d980cdc61b5c96181a26c33d77a8242 (patch) | |
tree | a5b6a96b9e375af6e17094cee7b8a4c0b4dc968f /usr.sbin/iscsictl | |
parent | Copy the updated proc.c from relayd to use the same file. Adjust (diff) | |
download | wireguard-openbsd-2fe39d326d980cdc61b5c96181a26c33d77a8242.tar.xz wireguard-openbsd-2fe39d326d980cdc61b5c96181a26c33d77a8242.zip |
Print bytes read and written in human readable form, like:
2849359 I2T calls (5 read, 2849352 writes)
5 data reads (2.3K bytes read)
2849352 data writes (43.5G bytes written)
2849358 T2I calls (2849358 done, 0 sense errors, 0 errors)
Diffstat (limited to 'usr.sbin/iscsictl')
-rw-r--r-- | usr.sbin/iscsictl/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/iscsictl/iscsictl.c | 14 |
2 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/iscsictl/Makefile b/usr.sbin/iscsictl/Makefile index 792761509fd..9a3dc1e01f9 100644 --- a/usr.sbin/iscsictl/Makefile +++ b/usr.sbin/iscsictl/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2012/09/13 05:50:15 claudio Exp $ +# $OpenBSD: Makefile,v 1.6 2014/04/21 20:20:37 claudio Exp $ .PATH: ${.CURDIR}/../iscsid @@ -14,5 +14,7 @@ CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual CFLAGS+= -Wsign-compare CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../iscsid YFLAGS= +LDADD= -lutil +DPADD+= ${LIBUTIL} .include <bsd.prog.mk> diff --git a/usr.sbin/iscsictl/iscsictl.c b/usr.sbin/iscsictl/iscsictl.c index f3fba0f01ff..5e1aea8ea4c 100644 --- a/usr.sbin/iscsictl/iscsictl.c +++ b/usr.sbin/iscsictl/iscsictl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iscsictl.c,v 1.7 2014/04/21 18:01:08 claudio Exp $ */ +/* $OpenBSD: iscsictl.c,v 1.8 2014/04/21 20:20:37 claudio Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -30,6 +30,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <util.h> #include "iscsid.h" #include "iscsictl.h" @@ -352,6 +353,7 @@ void show_vscsi_stats(struct ctrlmsghdr *cmh, struct pdu *pdu) { struct vscsi_stats *vs; + char buf[FMT_SCALED_STRSIZE]; if (cmh->len[0] != sizeof(struct vscsi_stats)) errx(1, "bad size of response"); @@ -367,10 +369,12 @@ show_vscsi_stats(struct ctrlmsghdr *cmh, struct pdu *pdu) vs->cnt_i2t_dir[1], vs->cnt_i2t_dir[2]); - printf("%llu data reads (%llu bytes read)\n", - vs->cnt_read, vs->bytes_rd); - printf("%llu data writes (%llu bytes written)\n", - vs->cnt_write, vs->bytes_wr); + if (fmt_scaled(vs->bytes_rd, buf) != 0) + (void)strlcpy(buf, "NaN", sizeof(buf)); + printf("%llu data reads (%s bytes read)\n", vs->cnt_read, buf); + if (fmt_scaled(vs->bytes_wr, buf) != 0) + (void)strlcpy(buf, "NaN", sizeof(buf)); + printf("%llu data writes (%s bytes written)\n", vs->cnt_write, buf); printf("%llu T2I calls (%llu done, %llu sense errors, %llu errors)\n", vs->cnt_t2i, |