From: claudio Date: Sun, 20 Apr 2014 22:22:18 +0000 (+0000) Subject: Add iscsictl bits to show the vscsi stats. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cf4672e7b964433d4af5f091b6885e22733c23d9;p=openbsd Add iscsictl bits to show the vscsi stats. --- diff --git a/usr.sbin/iscsictl/iscsictl.8 b/usr.sbin/iscsictl/iscsictl.8 index 11b760715fd..04d6558a8e9 100644 --- a/usr.sbin/iscsictl/iscsictl.8 +++ b/usr.sbin/iscsictl/iscsictl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: iscsictl.8,v 1.2 2012/06/26 21:09:44 claudio Exp $ +.\" $OpenBSD: iscsictl.8,v 1.3 2014/04/20 22:22:18 claudio Exp $ .\" .\" Copyright (c) 2010 David Gwynne .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 26 2012 $ +.Dd $Mdocdate: April 20 2014 $ .Dt ISCSICTL 8 .Os .Sh NAME @@ -48,6 +48,11 @@ The following commands are available: .Bl -tag -width Ds .It Cm reload Reload the configuration file. +.It Cm show Cm vscsi Cm stats +Show statistics of about +.Xr vscsi 4 +usage. +It shows how many calls were issued and how many bytes were read or written. .El .Sh FILES .Bl -tag -width "/var/run/iscsid.sockXX" -compact diff --git a/usr.sbin/iscsictl/iscsictl.c b/usr.sbin/iscsictl/iscsictl.c index 615ffa92de1..a46461aef90 100644 --- a/usr.sbin/iscsictl/iscsictl.c +++ b/usr.sbin/iscsictl/iscsictl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iscsictl.c,v 1.4 2012/05/02 18:02:45 gsoares Exp $ */ +/* $OpenBSD: iscsictl.c,v 1.5 2014/04/20 22:22:18 claudio Exp $ */ /* * Copyright (c) 2010 Claudio Jeker @@ -37,6 +37,7 @@ __dead void usage(void); void run_command(int, struct pdu *); struct pdu *ctl_getpdu(char *, size_t); int ctl_sendpdu(int, struct pdu *); +void show_vscsi_stats(struct ctrlmsghdr *, struct pdu *); char cbuf[CONTROL_READ_SIZE]; @@ -122,6 +123,16 @@ main (int argc, char* argv[]) case SHOW_SUM: usage(); /* NOTREACHED */ + case SHOW_VSCSI_STATS: + if ((pdu = pdu_new()) == NULL) + err(1, "pdu_new"); + if ((cmh = pdu_alloc(sizeof(*cmh))) == NULL) + err(1, "pdu_alloc"); + bzero(cmh, sizeof(*cmh)); + cmh->type = CTRL_VSCSI_STATS; + pdu_addbuf(pdu, cmh, sizeof(*cmh), 0); + run_command(csock, pdu); + break; case RELOAD: if ((cf = parse_config(confname)) == NULL) errx(1, "errors while loading configuration file."); @@ -224,8 +235,8 @@ run_command(int csock, struct pdu *pdu) pdu = ctl_getpdu(cbuf, n); cmh = pdu_getbuf(pdu, NULL, 0); - if (cmh == NULL) - break; + if (cmh == NULL) + break; switch (cmh->type) { case CTRL_SUCCESS: printf("command successful\n"); @@ -238,6 +249,10 @@ run_command(int csock, struct pdu *pdu) case CTRL_INPROGRESS: printf("command in progress...\n"); break; + case CTRL_VSCSI_STATS: + show_vscsi_stats(cmh, pdu); + done = 1; + break; } } } @@ -308,3 +323,34 @@ ctl_sendpdu(int fd, struct pdu *pdu) return -1; return 0; } + +void +show_vscsi_stats(struct ctrlmsghdr *cmh, struct pdu *pdu) +{ + struct vscsi_stats *vs; + + if (cmh->len[0] != sizeof(struct vscsi_stats)) + errx(1, "bad size of response"); + vs = pdu_getbuf(pdu, NULL, 1); + if (vs == NULL) + return; + + printf("VSCSI ioctl statistics:\n"); + printf("%u probe calls and %u detach calls\n", + vs->cnt_probe, vs->cnt_detach); + printf("%llu I2T calls (%llu read, %llu writes)\n", + vs->cnt_i2t, + 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); + + printf("%llu T2I calls (%llu done, %llu sense errors, %llu errors)\n", + vs->cnt_t2i, + vs->cnt_t2i_status[0], + vs->cnt_t2i_status[1], + vs->cnt_t2i_status[2]); +} diff --git a/usr.sbin/iscsictl/iscsictl.h b/usr.sbin/iscsictl/iscsictl.h index ffd0ab4d128..7daeb653237 100644 --- a/usr.sbin/iscsictl/iscsictl.h +++ b/usr.sbin/iscsictl/iscsictl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iscsictl.h,v 1.2 2011/04/27 19:20:01 claudio Exp $ */ +/* $OpenBSD: iscsictl.h,v 1.3 2014/04/20 22:22:18 claudio Exp $ */ /* * Copyright (c) 2009 David Gwynne @@ -34,6 +34,7 @@ enum actions { LOG_BRIEF, SHOW, SHOW_SUM, + SHOW_VSCSI_STATS, RELOAD, DISCOVERY }; diff --git a/usr.sbin/iscsictl/parser.c b/usr.sbin/iscsictl/parser.c index 39ad9659ac9..b7c30c900ef 100644 --- a/usr.sbin/iscsictl/parser.c +++ b/usr.sbin/iscsictl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.1 2010/09/24 09:45:17 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.2 2014/04/20 22:22:18 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby @@ -54,6 +54,7 @@ static const struct token t_main[]; static const struct token t_show[]; static const struct token t_log[]; static const struct token t_discovery[]; +static const struct token t_vscsi[]; static const struct token t_main[] = { {KEYWORD, "reload", RELOAD, NULL}, @@ -66,6 +67,7 @@ static const struct token t_main[] = { static const struct token t_show[] = { {NOTOKEN, "", NONE, NULL}, {KEYWORD, "summary", SHOW_SUM, NULL}, + {KEYWORD, "vscsi", NONE, t_vscsi}, {ENDTOKEN, "", NONE, NULL} }; @@ -80,6 +82,11 @@ static const struct token t_discovery[] = { {ENDTOKEN, "", NONE, NULL} }; +static const struct token t_vscsi[] = { + {KEYWORD, "stats", SHOW_VSCSI_STATS, NULL}, + {ENDTOKEN, "", NONE, NULL} +}; + static struct parse_result res; struct parse_result *