-.\" $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 <dlg@openbsd.org>
.\"
.\" 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
.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
-/* $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 <claudio@openbsd.org>
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];
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.");
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");
case CTRL_INPROGRESS:
printf("command in progress...\n");
break;
+ case CTRL_VSCSI_STATS:
+ show_vscsi_stats(cmh, pdu);
+ done = 1;
+ break;
}
}
}
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]);
+}
-/* $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 <norby@openbsd.org>
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},
static const struct token t_show[] = {
{NOTOKEN, "", NONE, NULL},
{KEYWORD, "summary", SHOW_SUM, NULL},
+ {KEYWORD, "vscsi", NONE, t_vscsi},
{ENDTOKEN, "", NONE, NULL}
};
{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 *