Fixed IOSTAT output totals (r/w was backwards). Removed zero output lines.

From:  Alan D. Brunelle <[EMAIL PROTECTED]>
Signed-off-by: Alan D. Brunelle <[EMAIL PROTECTED]>

---

 btt/iostat.c |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/btt/iostat.c b/btt/iostat.c
index 360d972..1dbd26b 100644
--- a/btt/iostat.c
+++ b/btt/iostat.c
@@ -107,6 +107,8 @@ void __dump_stats(__u64 stamp, int all, 
                dt = (double)(stamp-last_start) / 1.0e9;
                sp = &dip->stats;
        }
+       if (sp->ios[0] == 0 && sp->ios[1] == 0)
+               return;
 
        nios = (double)(sp->ios[0] + sp->ios[1]);
        nrqm = (double)(sp->rqm[0] + sp->rqm[1]);
@@ -143,17 +145,6 @@ void __dump_stats(__u64 stamp, int all, 
        fprintf(iostat_ofp, "%7.2lf ", await);
        fprintf(iostat_ofp, "%7.2lf ", svctm);
        fprintf(iostat_ofp, "%6.2lf", p_util);
-       if (all)
-               fprintf(iostat_ofp, "%8s\n", "TOTAL");
-       else {
-               fprintf(iostat_ofp, "%8.2lf\n", TO_SEC(stamp));
-               sp->rqm[0] = sp->rqm[1] = 0;
-               sp->ios[0] = sp->ios[1] = 0;
-               sp->sec[0] = sp->sec[1] = 0;
-               sp->wait = sp->svctm = 0;
-
-               sp->tot_qusz = sp->idle_time = 0.0;
-       }
 
        if (asp) {
                int i;
@@ -170,6 +161,18 @@ void __dump_stats(__u64 stamp, int all, 
                asp->svctm += svctm;
                asp->p_util += p_util;
        }
+
+       if (all)
+               fprintf(iostat_ofp, "%8s\n", "TOTAL");
+       else {
+               fprintf(iostat_ofp, "%8.2lf\n", TO_SEC(stamp));
+               sp->rqm[0] = sp->rqm[1] = 0;
+               sp->ios[0] = sp->ios[1] = 0;
+               sp->sec[0] = sp->sec[1] = 0;
+               sp->wait = sp->svctm = 0;
+
+               sp->tot_qusz = sp->idle_time = 0.0;
+       }
 }
 
 void __dump_stats_t(__u64 stamp, struct stats_t *asp, int all)
@@ -177,14 +180,14 @@ void __dump_stats_t(__u64 stamp, struct 
        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, "%8.2lf ", asp->rqm_s[0]);
        fprintf(iostat_ofp, "%7.2lf ", asp->ios_s[1]);
-       fprintf(iostat_ofp, "%9.2lf ", asp->sec_s[0]);
+       fprintf(iostat_ofp, "%7.2lf ", asp->ios_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[0]);
        fprintf(iostat_ofp, "%9.2lf ", asp->sec_s[1] / 2.0);
+       fprintf(iostat_ofp, "%9.2lf ", asp->sec_s[0] / 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);

Reply via email to