New devstat metrics for devstat_compute_statistics():

DSM_TOTAL_DURATION
  DSM_TOTAL_DURATION_READ
  DSM_TOTAL_DURATION_WRITE
  DSM_TOTAL_DURATION_FREE
  DSM_TOTAL_DURATION_OTHER
  DSM_TOTAL_BUSY_TIME
This commit is contained in:
Mikolaj Golub 2012-12-15 18:19:48 +00:00
parent efe3d4d7c9
commit fdd6757e71
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=244270
3 changed files with 75 additions and 9 deletions

View file

@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 18, 2003
.Dd December 15, 2012
.Dt DEVSTAT 3
.Os
.Sh NAME
@ -526,6 +526,35 @@ the acquisition of
.Fa previous
and
.Fa current .
.It Dv DSM_TOTAL_DURATION
type:
.Vt "long double *"
.Pp
The total duration of transactions, in seconds, between the acquisition of
.Fa previous
and
.Fa current .
.It Dv DSM_TOTAL_DURATION_OTHER
.It Dv DSM_TOTAL_DURATION_READ
.It Dv DSM_TOTAL_DURATION_WRITE
.It Dv DSM_TOTAL_DURATION_FREE
type:
.Vt "long double *"
.Pp
The total duration of transactions of the specified type between
the acquisition of
.Fa previous
and
.Fa current .
.It Dv DSM_TOTAL_BUSY_TIME
type:
.Vt "long double *"
.Pp
Total time the device had one or more transactions outstanding
between the acquisition of
.Fa previous
and
.Fa current .
.It Dv DSM_TOTAL_BLOCKS
type:
.Vt "uint64_t *"

View file

@ -133,6 +133,12 @@ struct devstat_args {
{ DSM_MS_PER_TRANSACTION_FREE, DEVSTAT_ARG_LD },
{ DSM_BUSY_PCT, DEVSTAT_ARG_LD },
{ DSM_QUEUE_LENGTH, DEVSTAT_ARG_UINT64 },
{ DSM_TOTAL_DURATION, DEVSTAT_ARG_LD },
{ DSM_TOTAL_DURATION_READ, DEVSTAT_ARG_LD },
{ DSM_TOTAL_DURATION_WRITE, DEVSTAT_ARG_LD },
{ DSM_TOTAL_DURATION_FREE, DEVSTAT_ARG_LD },
{ DSM_TOTAL_DURATION_OTHER, DEVSTAT_ARG_LD },
{ DSM_TOTAL_BUSY_TIME, DEVSTAT_ARG_LD },
};
static const char *namelist[] = {
@ -1217,11 +1223,13 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
u_int64_t totaltransfers, totaltransfersread, totaltransferswrite;
u_int64_t totaltransfersother, totalblocks, totalblocksread;
u_int64_t totalblockswrite, totaltransfersfree, totalblocksfree;
long double totalduration, totaldurationread, totaldurationwrite;
long double totaldurationfree, totaldurationother;
va_list ap;
devstat_metric metric;
u_int64_t *destu64;
long double *destld;
int retval, i;
int retval;
retval = 0;
@ -1263,6 +1271,13 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
totalblocksfree /= 512;
}
totaldurationread = DELTA_T(duration[DEVSTAT_READ]);
totaldurationwrite = DELTA_T(duration[DEVSTAT_WRITE]);
totaldurationfree = DELTA_T(duration[DEVSTAT_FREE]);
totaldurationother = DELTA_T(duration[DEVSTAT_NO_DATA]);
totalduration = totaldurationread + totaldurationwrite +
totaldurationfree + totaldurationother;
va_start(ap, etime);
while ((metric = (devstat_metric)va_arg(ap, devstat_metric)) != 0) {
@ -1484,9 +1499,7 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
*/
case DSM_MS_PER_TRANSACTION:
if (totaltransfers > 0) {
*destld = 0;
for (i = 0; i < DEVSTAT_N_TRANS_FLAGS; i++)
*destld += DELTA_T(duration[i]);
*destld = totalduration;
*destld /= totaltransfers;
*destld *= 1000;
} else
@ -1499,7 +1512,7 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
*/
case DSM_MS_PER_TRANSACTION_READ:
if (totaltransfersread > 0) {
*destld = DELTA_T(duration[DEVSTAT_READ]);
*destld = totaldurationread;
*destld /= totaltransfersread;
*destld *= 1000;
} else
@ -1507,7 +1520,7 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
break;
case DSM_MS_PER_TRANSACTION_WRITE:
if (totaltransferswrite > 0) {
*destld = DELTA_T(duration[DEVSTAT_WRITE]);
*destld = totaldurationwrite;
*destld /= totaltransferswrite;
*destld *= 1000;
} else
@ -1515,7 +1528,7 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
break;
case DSM_MS_PER_TRANSACTION_FREE:
if (totaltransfersfree > 0) {
*destld = DELTA_T(duration[DEVSTAT_FREE]);
*destld = totaldurationfree;
*destld /= totaltransfersfree;
*destld *= 1000;
} else
@ -1523,7 +1536,7 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
break;
case DSM_MS_PER_TRANSACTION_OTHER:
if (totaltransfersother > 0) {
*destld = DELTA_T(duration[DEVSTAT_NO_DATA]);
*destld = totaldurationother;
*destld /= totaltransfersother;
*destld *= 1000;
} else
@ -1541,6 +1554,24 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous,
case DSM_QUEUE_LENGTH:
*destu64 = current->start_count - current->end_count;
break;
case DSM_TOTAL_DURATION:
*destld = totalduration;
break;
case DSM_TOTAL_DURATION_READ:
*destld = totaldurationread;
break;
case DSM_TOTAL_DURATION_WRITE:
*destld = totaldurationwrite;
break;
case DSM_TOTAL_DURATION_FREE:
*destld = totaldurationfree;
break;
case DSM_TOTAL_DURATION_OTHER:
*destld = totaldurationother;
break;
case DSM_TOTAL_BUSY_TIME:
*destld = DELTA_T(busy_time);
break;
/*
* XXX: comment out the default block to see if any case's are missing.
*/

View file

@ -97,6 +97,12 @@ typedef enum {
DSM_MS_PER_TRANSACTION_FREE,
DSM_BUSY_PCT,
DSM_QUEUE_LENGTH,
DSM_TOTAL_DURATION,
DSM_TOTAL_DURATION_READ,
DSM_TOTAL_DURATION_WRITE,
DSM_TOTAL_DURATION_FREE,
DSM_TOTAL_DURATION_OTHER,
DSM_TOTAL_BUSY_TIME,
DSM_MAX
} devstat_metric;