From 4a5cddba3b29a5356f883563b4909a0ee5a699ea Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 1 Dec 2006 10:49:19 +0100 Subject: [PATCH] [PATCH] BTT patch: (1/3) 'iostat' totals Added in totals for IOSTAT output (per snapshot and overall totals) Signed-off-by: Alan D. Brunelle Signed-off-by: Jens Axboe --- btt/globals.h | 6 ++++++ btt/iostat.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/btt/globals.h b/btt/globals.h index 3bafc91..1a785f3 100644 --- a/btt/globals.h +++ b/btt/globals.h @@ -137,6 +137,12 @@ struct stats { int cur_qusz, cur_dev; }; +struct stats_t { + double n; + double rqm_s[2], ios_s[2], sec_s[2]; + double avgrq_sz, avgqu_sz, await, svctm, p_util; +}; + struct d_info { struct list_head all_head, hash_head; void *heads; diff --git a/btt/iostat.c b/btt/iostat.c index 92b6eae..f2c54dc 100644 --- a/btt/iostat.c +++ b/btt/iostat.c @@ -92,7 +92,7 @@ void update_idle_time(struct d_info *dip, double now, int force) dip->stats.last_dev_change = dip->all_stats.last_dev_change = now; } -void __dump_stats(__u64 stamp, int all, struct d_info *dip) +void __dump_stats(__u64 stamp, int all, struct d_info *dip, struct stats_t *asp) { char hdr[16]; struct stats *sp; @@ -154,20 +154,63 @@ void __dump_stats(__u64 stamp, int all, struct d_info *dip) sp->tot_qusz = sp->idle_time = 0.0; } + + if (asp) { + int i; + + asp->n += 1.0; + for (i = 0; i < 2; i++) { + asp->rqm_s[i] += ((double)sp->rqm[i] / dt); + asp->ios_s[i] += ((double)sp->ios[i] / dt); + asp->sec_s[i] += ((double)sp->sec[i] / dt); + } + asp->avgrq_sz += avgrq_sz; + asp->avgqu_sz += (double)sp->tot_qusz / dt; + asp->await += await; + asp->svctm += svctm; + asp->p_util += p_util; + } +} + +void __dump_stats_t(__u64 stamp, struct stats_t *asp, int all) +{ + if (asp->n < 2.0) return; // What's the point? + + fprintf(iostat_ofp, "%-11s ", "TOTAL"); + fprintf(iostat_ofp, "%8.2lf ", asp->rqm_s[0]); + fprintf(iostat_ofp, "%8.2lf ", asp->rqm_s[1]); + fprintf(iostat_ofp, "%7.2lf ", asp->ios_s[0]); + fprintf(iostat_ofp, "%7.2lf ", asp->ios_s[1]); + fprintf(iostat_ofp, "%9.2lf ", asp->sec_s[0]); + fprintf(iostat_ofp, "%9.2lf ", asp->sec_s[1]); + fprintf(iostat_ofp, "%9.2lf ", asp->sec_s[0] / 2.0); + fprintf(iostat_ofp, "%9.2lf ", asp->sec_s[1] / 2.0); + fprintf(iostat_ofp, "%8.2lf ", asp->avgrq_sz / asp->n); + fprintf(iostat_ofp, "%8.2lf ", asp->avgqu_sz / asp->n); + fprintf(iostat_ofp, "%7.2lf ", asp->await / asp->n); + fprintf(iostat_ofp, "%7.2lf ", asp->svctm / asp->n); + fprintf(iostat_ofp, "%6.2lf", asp->p_util / asp->n); + if (all) + fprintf(iostat_ofp, "%8s\n", "TOTAL"); + else + fprintf(iostat_ofp, "%8.2lf\n", TO_SEC(stamp)); } void iostat_dump_stats(__u64 stamp, int all) { struct d_info *dip; + struct stats_t as; + memset(&as, 0, sizeof(struct stats_t)); if (all) dump_hdr(); + if (devices == NULL) { struct list_head *p; __list_for_each(p, &all_devs) { dip = list_entry(p, struct d_info, all_head); - __dump_stats(stamp, all, dip); + __dump_stats(stamp, all, dip, &as); } } else { @@ -177,12 +220,15 @@ void iostat_dump_stats(__u64 stamp, int all) while (p && ((i = sscanf(p, "%u,%u", &mjr, &mnr)) == 2)) { dip = __dip_find((__u32)((mjr << MINORBITS) | mnr)); - __dump_stats(stamp, all, dip); + __dump_stats(stamp, all, dip, &as); p = strchr(p, ';'); if (p) p++; } } + + __dump_stats_t(stamp, &as, all); + if (!all && iostat_ofp) fprintf(iostat_ofp, "\n"); } -- 2.25.1