From: claudio Date: Mon, 21 Apr 2014 20:20:37 +0000 (+0000) Subject: Print bytes read and written in human readable form, like: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2fe39d326d980cdc61b5c96181a26c33d77a8242;p=openbsd 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) --- 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 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 @@ -30,6 +30,7 @@ #include #include #include +#include #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,