summaryrefslogtreecommitdiffstats
path: root/lib/libdevstat
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2012-12-15 18:19:48 +0000
committertrociny <trociny@FreeBSD.org>2012-12-15 18:19:48 +0000
commit7c744361c22d7640b2f1c05924fd05090c957fd5 (patch)
tree763b78a430041a8f017cc1c2445bb1b9b1d81cf2 /lib/libdevstat
parentc10369861888dc07ce1ab8061d18fc776c5d60a1 (diff)
downloadFreeBSD-src-7c744361c22d7640b2f1c05924fd05090c957fd5.zip
FreeBSD-src-7c744361c22d7640b2f1c05924fd05090c957fd5.tar.gz
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
Diffstat (limited to 'lib/libdevstat')
-rw-r--r--lib/libdevstat/devstat.331
-rw-r--r--lib/libdevstat/devstat.c47
-rw-r--r--lib/libdevstat/devstat.h6
3 files changed, 75 insertions, 9 deletions
diff --git a/lib/libdevstat/devstat.3 b/lib/libdevstat/devstat.3
index 8d0ce4d..39be6ac 100644
--- a/lib/libdevstat/devstat.3
+++ b/lib/libdevstat/devstat.3
@@ -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 *"
diff --git a/lib/libdevstat/devstat.c b/lib/libdevstat/devstat.c
index ff0767a..0f313fb 100644
--- a/lib/libdevstat/devstat.c
+++ b/lib/libdevstat/devstat.c
@@ -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.
*/
diff --git a/lib/libdevstat/devstat.h b/lib/libdevstat/devstat.h
index 7717cb1..9471f93 100644
--- a/lib/libdevstat/devstat.h
+++ b/lib/libdevstat/devstat.h
@@ -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;
OpenPOWER on IntegriCloud