]> granicus.if.org Git - sysstat/commitdiff
sadf: Add discard I/O metric to all output formats
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 1 Dec 2018 10:02:12 +0000 (11:02 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 1 Dec 2018 10:02:12 +0000 (11:02 +0100)
Add new discard I/O metric to each of sadf's output formats (JSON, XML,
SVG, etc.)

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
json_stats.c
raw_stats.c
rndr_stats.c
svg_stats.c
xml_stats.c

index e67e96ecbddec2bb26268e1fdc65e399e3eb43ad..7f82b4900ac9bf9cf174dcf15319836e2d8f98af 100644 (file)
@@ -748,8 +748,10 @@ __print_funct_t json_print_disk_stats(struct activity *a, int curr, int tab,
                         "\"tps\": %.2f, "
                         "\"rd_sec\": %.2f, "
                         "\"wr_sec\": %.2f, "
+                        "\"dc_sec\": %.2f, "
                         "\"rkB\": %.2f, "
                         "\"wkB\": %.2f, "
+                        "\"dkB\": %.2f, "
                         "\"avgrq-sz\": %.2f, "
                         "\"areq-sz\": %.2f, "
                         "\"avgqu-sz\": %.2f, "
@@ -761,8 +763,10 @@ __print_funct_t json_print_disk_stats(struct activity *a, int curr, int tab,
                         S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
                         S_VALUE(sdp->rd_sect, sdc->rd_sect, itv), /* Unit = sectors (for backward compatibility) */
                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
+                        S_VALUE(sdp->dc_sect, sdc->dc_sect, itv),
                         S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
+                        S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
                         /* See iostat for explanations */
                         xds.arqsz,     /* Unit = sectors (for backward compatibility) */
                         xds.arqsz / 2,
index 5313755992d1ff0edc92a4caab40ab44abe149a5..38ade16535253ee5d1b092e8ab0292e3b201376c 100644 (file)
@@ -559,10 +559,14 @@ __print_funct_t raw_print_disk_stats(struct activity *a, char *timestr, int curr
                pval((unsigned long long) sdp->rd_sect, (unsigned long long) sdc->rd_sect);
                printf(" %s", pfield(NULL, 0));
                pval((unsigned long long) sdp->wr_sect, (unsigned long long) sdc->wr_sect);
+               printf(" %s", pfield(NULL, 0));
+               pval((unsigned long long) sdp->dc_sect, (unsigned long long) sdc->dc_sect);
                printf(" rd_ticks");
                pval((unsigned long long) sdp->rd_ticks, (unsigned long long) sdc->rd_ticks);
                printf(" wr_ticks");
                pval((unsigned long long) sdp->wr_ticks, (unsigned long long) sdc->wr_ticks);
+               printf(" dc_ticks");
+               pval((unsigned long long) sdp->dc_ticks, (unsigned long long) sdc->dc_ticks);
                printf(" tot_ticks");
                pval((unsigned long long) sdp->tot_ticks, (unsigned long long) sdc->tot_ticks);
                pfield(NULL, 0); /* Skip areq-sz */
index a54229f968a209a36d9dcce1f1853c54a6d89c73..72ade0174786ad2b80e136a8b8ced7188b90e0f8 100644 (file)
@@ -1110,6 +1110,13 @@ __print_funct_t render_disk_stats(struct activity *a, int isdb, char *pre,
                       S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
                       NULL);
 
+               render(isdb, pre, PT_NOFLAG,
+                      "%s\tdkB/s", NULL,
+                      cons(sv, dev_name, NULL),
+                      NOVAL,
+                      S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
+                      NULL);
+
                render(isdb, pre, PT_NOFLAG,
                       "%s\tareq-sz", NULL,
                       cons(sv, dev_name, NULL),
index 8a75921a59fdb7f87f4cf1cafbdae68fca9ef0d4..9ebd76b1c4c12896d5413e92379ace37561023bc 100644 (file)
@@ -2013,35 +2013,35 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
 {
        struct stats_disk *sdc, *sdp, sdpzero;
        struct ext_disk_stats xds;
-       int group[] = {1, 2, 2, 1, 1};
+       int group[] = {1, 3, 2, 1, 1};
        int g_type[] = {SVG_LINE_GRAPH, SVG_LINE_GRAPH, SVG_LINE_GRAPH,
                        SVG_LINE_GRAPH, SVG_BAR_GRAPH};
        char *title[] = {"Block devices statistics (1)", "Block devices statistics (2)",
                         "Block devices statistics (3)", "Block devices statistics (4)",
                         "Block devices statistics (5)"};
        char *g_title[] = {"tps",
-                          "rkB/s", "wkB/s",
+                          "rkB/s", "wkB/s", "dkB/s",
                           "areq-sz", "aqu-sz",
                           "await",
                           "%util"};
        int g_fields[] = {0, 1, 2};
-       int nr_arrays = 8;
+       int nr_arrays = 9;
        unsigned int local_types_nr[] = {1, 0, 0};
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
        char *item_name;
-       double rkB, wkB, aqusz;
+       double rkB, wkB, dkB, aqusz;
        int i, j, k, pos, restart, *unregistered;
 
        if (action & F_BEGIN) {
                /*
-                * Allocate arrays (#0..6) that will contain the graphs data
+                * Allocate arrays (#0..7) that will contain the graphs data
                 * and the min/max values.
-                * Also allocate one additional array (#7) for each disk device:
-                * spmax + 7 will contain the device major number,
-                * spmin + 7 will contain the device minor number,
-                * outsize + 7 will contain a positive value (TRUE) if the device
+                * Also allocate one additional array (#8) for each disk device:
+                * spmax + 8 will contain the device major number,
+                * spmin + 8 will contain the device minor number,
+                * outsize + 8 will contain a positive value (TRUE) if the device
                 * has either still not been registered, or has been unregistered.
                 */
                out = allocate_graph_lines(nr_arrays * a->item_list_sz, &outsize, &spmin, &spmax);
@@ -2055,7 +2055,7 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                 * possibly unregistered for all graphs.
                 */
                for (k = 0; k < a->item_list_sz; k++) {
-                       unregistered = outsize + k * nr_arrays + 7;
+                       unregistered = outsize + k * nr_arrays + 8;
                        if (*unregistered == FALSE) {
                                *unregistered = MAYBE;
                        }
@@ -2077,15 +2077,15 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
 
                        /* Look for corresponding graph */
                        for (k = 0; k < a->item_list_sz; k++) {
-                               if ((sdc->major == *(spmax + k * nr_arrays + 7)) &&
-                                   (sdc->minor == *(spmin + k * nr_arrays + 7)))
+                               if ((sdc->major == *(spmax + k * nr_arrays + 8)) &&
+                                   (sdc->minor == *(spmin + k * nr_arrays + 8)))
                                        /* Graph found! */
                                        break;
                        }
                        if (k == a->item_list_sz) {
                                /* Graph not found: Look for first free entry */
                                for (k = 0; k < a->item_list_sz; k++) {
-                                       if (*(spmax + k * nr_arrays + 7) == -DBL_MAX)
+                                       if (*(spmax + k * nr_arrays + 8) == -DBL_MAX)
                                                break;
                                }
                                if (k == a->item_list_sz) {
@@ -2098,7 +2098,7 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                                }
                        }
                        pos = k * nr_arrays;
-                       unregistered = outsize + pos + 7;
+                       unregistered = outsize + pos + 8;
 
                        /*
                         * If current device was marked as previously unregistered,
@@ -2110,10 +2110,10 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                        }
                        *unregistered = FALSE;
 
-                       if (*(spmax + pos + 7) == -DBL_MAX) {
+                       if (*(spmax + pos + 8) == -DBL_MAX) {
                                /* Save device major and minor numbers (if not already done) */
-                               *(spmax + pos + 7) = sdc->major;
-                               *(spmin + pos + 7) = sdc->minor;
+                               *(spmax + pos + 8) = sdc->major;
+                               *(spmin + pos + 8) = sdc->minor;
                        }
 
                        j = check_disk_reg(a, curr, !curr, i);
@@ -2131,6 +2131,7 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
 
                        rkB = S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2;
                        wkB = S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2;
+                       dkB = S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2;
                        if (rkB < *(spmin + pos + 1)) {
                                *(spmin + pos + 1) = rkB;
                        }
@@ -2143,32 +2144,38 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                        if (wkB > *(spmax + pos + 2)) {
                                *(spmax + pos + 2) = wkB;
                        }
+                       if (dkB < *(spmin + pos + 3)) {
+                               *(spmin + pos + 3) = dkB;
+                       }
+                       if (dkB > *(spmax + pos + 3)) {
+                               *(spmax + pos + 3) = dkB;
+                       }
 
                        compute_ext_disk_stats(sdc, sdp, itv, &xds);
-                       if ((xds.arqsz / 2) < *(spmin + pos + 3)) {
-                               *(spmin + pos + 3) = xds.arqsz / 2;
+                       if ((xds.arqsz / 2) < *(spmin + pos + 4)) {
+                               *(spmin + pos + 4) = xds.arqsz / 2;
                        }
-                       if ((xds.arqsz / 2) > *(spmax + pos + 3)) {
-                               *(spmax + pos + 3) = xds.arqsz / 2;
+                       if ((xds.arqsz / 2) > *(spmax + pos + 4)) {
+                               *(spmax + pos + 4) = xds.arqsz / 2;
                        }
                        aqusz = S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0;
-                       if (aqusz < *(spmin + pos + 4)) {
-                               *(spmin + pos + 4) = aqusz;
+                       if (aqusz < *(spmin + pos + 5)) {
+                               *(spmin + pos + 5) = aqusz;
                        }
-                       if (aqusz > *(spmax + pos + 4)) {
-                               *(spmax + pos + 4) = aqusz;
+                       if (aqusz > *(spmax + pos + 5)) {
+                               *(spmax + pos + 5) = aqusz;
                        }
-                       if (xds.await < *(spmin + pos + 5)) {
-                               *(spmin + pos + 5) = xds.await;
+                       if (xds.await < *(spmin + pos + 6)) {
+                               *(spmin + pos + 6) = xds.await;
                        }
-                       if (xds.await > *(spmax + pos + 5)) {
-                               *(spmax + pos + 5) = xds.await;
+                       if (xds.await > *(spmax + pos + 6)) {
+                               *(spmax + pos + 6) = xds.await;
                        }
-                       if ((xds.util / 10.0) < *(spmin + pos + 6)) {
-                               *(spmin + pos + 6) = xds.util / 10.0;
+                       if ((xds.util / 10.0) < *(spmin + pos + 7)) {
+                               *(spmin + pos + 7) = xds.util / 10.0;
                        }
-                       if ((xds.util / 10.0) > *(spmax + pos + 6)) {
-                               *(spmax + pos + 6) = xds.util / 10.0;
+                       if ((xds.util / 10.0) > *(spmax + pos + 7)) {
+                               *(spmax + pos + 7) = xds.util / 10.0;
                        }
 
                        /* tps */
@@ -2183,27 +2190,31 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                        lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
                                 out + pos + 2, outsize + pos + 2, restart);
+                       /* dkB/s */
+                       lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                                S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
+                                out + pos + 3, outsize + pos + 3, restart);
                        /* areq-sz */
                        lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 xds.arqsz / 2,
-                                out + pos + 3, outsize + pos + 3, restart);
+                                out + pos + 4, outsize + pos + 4, restart);
                        /* aqu-sz */
                        lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 aqusz,
-                                out + pos + 4, outsize + pos + 4, restart);
+                                out + pos + 5, outsize + pos + 5, restart);
                        /* await */
                        lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 xds.await,
-                                out + pos + 5, outsize + pos + 5, restart);
+                                out + pos + 6, outsize + pos + 6, restart);
                        /* %util */
                        brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 0.0, xds.util / 10.0,
-                                out + pos + 6, outsize + pos + 6, svg_p->dt);
+                                out + pos + 7, outsize + pos + 7, svg_p->dt);
                }
 
                /* Mark devices not seen here as now unregistered */
                for (k = 0; k < a->item_list_sz; k++) {
-                       unregistered = outsize + k * nr_arrays + 7;
+                       unregistered = outsize + k * nr_arrays + 8;
                        if (*unregistered != FALSE) {
                                *unregistered = TRUE;
                        }
@@ -2220,7 +2231,7 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                                continue;
 
                        /* Get device name */
-                       item_name = get_sa_devname(*(spmax + pos + 7), *(spmin + pos + 7), flags);
+                       item_name = get_sa_devname(*(spmax + pos + 8), *(spmin + pos + 8), flags);
 
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
index 505a1ebd26cd85eddb5de5213c25d9f7702b7c2b..618a4852f88f8a3ce431817bac9e59f5289fb557 100644 (file)
@@ -728,8 +728,10 @@ __print_funct_t xml_print_disk_stats(struct activity *a, int curr, int tab,
                        "tps=\"%.2f\" "
                        "rd_sec=\"%.2f\" "
                        "wr_sec=\"%.2f\" "
+                       "dc_sec=\"%.2f\" "
                        "rkB=\"%.2f\" "
                        "wkB=\"%.2f\" "
+                       "dkB=\"%.2f\" "
                        "avgrq-sz=\"%.2f\" "
                        "areq-sz=\"%.2f\" "
                        "avgqu-sz=\"%.2f\" "
@@ -741,8 +743,10 @@ __print_funct_t xml_print_disk_stats(struct activity *a, int curr, int tab,
                        S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
                        S_VALUE(sdp->rd_sect, sdc->rd_sect, itv), /* Unit = sectors (for backward compatibility) */
                        S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
+                       S_VALUE(sdp->dc_sect, sdc->dc_sect, itv),
                        S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
                        S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
+                       S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
                        /* See iostat for explanations */
                        xds.arqsz,      /* Unit = sectors (for backward compatibility) */
                        xds.arqsz / 2,