]> granicus.if.org Git - sysstat/commitdiff
sadf: Make option -j work with filesystems statistics
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 7 Nov 2020 08:23:52 +0000 (09:23 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 7 Nov 2020 08:23:52 +0000 (09:23 +0100)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
json_stats.c
pcp_stats.c
raw_stats.c
rndr_stats.c
sadf_misc.c
svg_stats.c
xml_stats.c

index d4861ce356addbc56f0d70e5a0385acff95ce86f..fd333c5fcf6affba59f077d5f7925a549b79acec 100644 (file)
@@ -2207,16 +2207,19 @@ __print_funct_t json_print_filesystem_stats(struct activity *a, int curr, int ta
        int i;
        struct stats_filesystem *sfc;
        int sep = FALSE;
+       char *dev_name;
 
        xprintf(tab++, "\"filesystems\": [");
 
        for (i = 0; i < a->nr[curr]; i++) {
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               /* Get name to display (persistent or standard fs name, or mount point) */
+               dev_name = get_fs_name_to_display(a, flags, sfc);
+
                if (a->item_list != NULL) {
                        /* A list of devices has been entered on the command line */
-                       if (!search_list_item(a->item_list,
-                                             DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                       if (!search_list_item(a->item_list, dev_name))
                                /* Device not found */
                                continue;
                }
@@ -2235,7 +2238,7 @@ __print_funct_t json_print_filesystem_stats(struct activity *a, int curr, int ta
                         "\"Iused\": %llu, "
                         "\"%%Iused\": %.2f}",
                         DISPLAY_MOUNT(a->opt_flags) ? "mountpoint" : "filesystem",
-                        DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
+                        dev_name,
                         (double) sfc->f_bfree / 1024 / 1024,
                         (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
                         sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
index 002fca4afb2127549faa4c8b0306999f4162dd38..253f0b3abd521c2665c5d34306408a154f5cc640 100644 (file)
@@ -2042,56 +2042,51 @@ __print_funct_t pcp_print_filesystem_stats(struct activity *a, int curr, unsigne
        int i;
        struct stats_filesystem *sfc;
        char buf[64];
+       char *dev_name;
 
        for (i = 0; i < a->nr[curr]; i++) {
-
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               /* Get name to display (persistent or standard fs name, or mount point) */
+               dev_name = get_fs_name_to_display(a, flags, sfc);
+
                if (a->item_list != NULL) {
                        /* A list of devices has been entered on the command line */
-                       if (!search_list_item(a->item_list,
-                                             DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                       if (!search_list_item(a->item_list, dev_name))
                                /* Device not found */
                                continue;
                }
 
                snprintf(buf, sizeof(buf), "%.0f",
                         (double) sfc->f_bfree / 1024 / 1024);
-               pmiPutValue("fs.util.fsfree",
-                           DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+               pmiPutValue("fs.util.fsfree", dev_name, buf);
 
                snprintf(buf, sizeof(buf), "%.0f",
                         (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024);
-               pmiPutValue("fs.util.fsused",
-                           DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+               pmiPutValue("fs.util.fsused", dev_name, buf);
 
                snprintf(buf, sizeof(buf), "%f",
                         sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
                                       : 0.0);
-               pmiPutValue("fs.util.fsused_pct",
-                           DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+               pmiPutValue("fs.util.fsused_pct", dev_name, buf);
 
                snprintf(buf, sizeof(buf), "%f",
                         sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
                                       : 0.0);
-               pmiPutValue("fs.util.ufsused_pct",
-                           DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+               pmiPutValue("fs.util.ufsused_pct", dev_name, buf);
 
                snprintf(buf, sizeof(buf), "%llu",
                         sfc->f_ffree);
-               pmiPutValue("fs.util.ifree",
-                           DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+               pmiPutValue("fs.util.ifree", dev_name, buf);
 
                snprintf(buf, sizeof(buf), "%llu",
                         sfc->f_files - sfc->f_ffree);
-               pmiPutValue("fs.util.iused",
-                           DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+               pmiPutValue("fs.util.iused", dev_name, buf);
 
                snprintf(buf, sizeof(buf), "%f",
                         sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
                                      : 0.0);
-               pmiPutValue("fs.util.iused_pct",
-                           DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, buf);
+               pmiPutValue("fs.util.iused_pct", dev_name, buf);
        }
 #endif /* HAVE_PCP */
 }
index 189e32400e5a30c86af9998b7534e41651f70c6f..7e5ef1379093885ede94294ac2850ba1737d4269 100644 (file)
@@ -1501,20 +1501,23 @@ __print_funct_t raw_print_filesystem_stats(struct activity *a, char *timestr, in
 {
        int i;
        struct stats_filesystem *sfc;
+       char *dev_name;
 
        for (i = 0; i < a->nr[curr]; i++) {
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               /* Get name to display (persistent or standard fs name, or mount point) */
+               dev_name = get_fs_name_to_display(a, flags, sfc);
+
                if (a->item_list != NULL) {
                        /* A list of devices has been entered on the command line */
-                       if (!search_list_item(a->item_list,
-                                             DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                       if (!search_list_item(a->item_list, dev_name))
                                /* Device not found */
                                continue;
                }
 
                printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST + DISPLAY_MOUNT(a->opt_flags)),
-                      DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name);
+                      dev_name);
                printf(" f_bfree; %llu;", sfc->f_bfree);
                printf(" f_blocks; %llu;", sfc->f_blocks);
                printf(" f_bavail; %llu;", sfc->f_bavail);
index f4d0eb6e427fc0316d4fb89961059d5189fc0470..5dc90488391b1134cae71bfb1b3ecdbba66a9a5e 100644 (file)
@@ -2911,14 +2911,17 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
 {
        int i;
        struct stats_filesystem *sfc;
+       char *dev_name;
 
        for (i = 0; i < a->nr[curr]; i++) {
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               /* Get name to display (persistent or standard fs name, or mount point) */
+               dev_name = get_fs_name_to_display(a, flags, sfc);
+
                if (a->item_list != NULL) {
                        /* A list of devices has been entered on the command line */
-                       if (!search_list_item(a->item_list,
-                                             DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                       if (!search_list_item(a->item_list, dev_name))
                                /* Device not found */
                                continue;
                }
@@ -2926,7 +2929,7 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
                render(isdb, pre, PT_USERND,
                       "%s\tMBfsfree",
                       "%s",
-                      cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+                      cons(sv, dev_name, NOVAL),
                       NOVAL,
                       (double) sfc->f_bfree / 1024 / 1024,
                       NULL);
@@ -2934,7 +2937,7 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
                render(isdb, pre, PT_USERND,
                       "%s\tMBfsused",
                       NULL,
-                      cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+                      cons(sv, dev_name, NOVAL),
                       NOVAL,
                       (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
                       NULL);
@@ -2942,7 +2945,7 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
                render(isdb, pre, PT_NOFLAG,
                       "%s\t%%fsused",
                       NULL,
-                      cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+                      cons(sv, dev_name, NOVAL),
                       NOVAL,
                       sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
                                     : 0.0,
@@ -2951,7 +2954,7 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
                render(isdb, pre, PT_NOFLAG,
                       "%s\t%%ufsused",
                       NULL,
-                      cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+                      cons(sv, dev_name, NOVAL),
                       NOVAL,
                       sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
                                     : 0.0,
@@ -2960,7 +2963,7 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
                render(isdb, pre, PT_USEINT,
                       "%s\tIfree",
                       NULL,
-                      cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+                      cons(sv, dev_name, NOVAL),
                       sfc->f_ffree,
                       NOVAL,
                       NULL);
@@ -2968,7 +2971,7 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
                render(isdb, pre, PT_USEINT,
                       "%s\tIused",
                       NULL,
-                      cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+                      cons(sv, dev_name, NOVAL),
                       sfc->f_files - sfc->f_ffree,
                       NOVAL,
                       NULL);
@@ -2977,7 +2980,7 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
                       (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN),
                       "%s\t%%Iused",
                       NULL,
-                      cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
+                      cons(sv, dev_name, NOVAL),
                       NOVAL,
                       sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
                                    : 0.0,
index de23109363c1b4eaf49271d93e9405f2d4732029..84f5be59ee222ee6b7aefd4cf395d5724a5c8be1 100644 (file)
@@ -1539,7 +1539,7 @@ __nr_t count_new_filesystem(struct activity *a, int curr)
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
                nr += add_list_item(&(a->item_list),
-                                   DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
+                                   get_fs_name_to_display(a, flags, sfc),
                                    MAX_FS_LEN);
        }
 
index 987e737e46fd4b6a4bd8f69bc9c201c2f38f5c65..622bd3511c6da8f75968a600481f4dd7f86cbbe8 100644 (file)
@@ -4706,10 +4706,11 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                           "%ufsused", "%fsused",
                           "Ifree/1000", "Iused/1000",
                           "%Iused"};
+       int nr_arrays = 8;
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char *item_name;
+       char *dev_name, *item_name;
        double tval;
        int i, k, pos, restart;
 
@@ -4717,11 +4718,10 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                /*
                 * Allocate arrays (#0..6) that will contain the graphs data
                 * and the min/max values.
-                * Also allocate two additional arrays (#7..8) for each filesystem:
-                 * out + 7 will contain the filesystem name,
-                * out + 8 will contain the mount point.
+                * Also allocate an additional arrays (#7) for each filesystem:
+                 * out + 7 will contain the persistent or standard fs name, or mount point.
                 */
-               out = allocate_graph_lines(9 * a->item_list_sz, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(nr_arrays * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -4729,18 +4729,20 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                for (i = 0; i < a->nr[curr]; i++) {
                        sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+                       /* Get name to display (persistent or standard fs name, or mount point) */
+                       dev_name = get_fs_name_to_display(a, flags, sfc);
+
                        if (a->item_list != NULL) {
                                /* A list of devices has been entered on the command line */
-                               if (!search_list_item(a->item_list,
-                                                     DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                               if (!search_list_item(a->item_list, dev_name))
                                        /* Device not found */
                                        continue;
                        }
 
                        /* Look for corresponding graph */
                        for (k = 0; k < a->item_list_sz; k++) {
-                               item_name = *(out + k * 9 + 7);
-                               if (!strcmp(sfc->fs_name, item_name))
+                               item_name = *(out + k * nr_arrays + 7);
+                               if (!strcmp(dev_name, item_name))
                                        /* Graph found! */
                                        break;
                        }
@@ -4748,7 +4750,7 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                        if (k == a->item_list_sz) {
                                /* Graph not found: Look for first free entry */
                                for (k = 0; k < a->item_list_sz; k++) {
-                                       item_name = *(out + k * 9 + 7);
+                                       item_name = *(out + k * nr_arrays + 7);
                                        if (!strcmp(item_name, ""))
                                                break;
                                }
@@ -4762,15 +4764,12 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                                }
                        }
 
-                       pos = k * 9;
+                       pos = k * nr_arrays;
 
                        item_name = *(out + pos + 7);
                        if (!item_name[0]) {
                                /* Save filesystem name and mount point (if not already done) */
-                               strncpy(item_name, sfc->fs_name, CHUNKSIZE);
-                               item_name[CHUNKSIZE - 1] = '\0';
-                               item_name = *(out + pos + 8);
-                               strncpy(item_name, sfc->mountp, CHUNKSIZE);
+                               strncpy(item_name, dev_name, CHUNKSIZE);
                                item_name[CHUNKSIZE - 1] = '\0';
                        }
 
@@ -4888,11 +4887,11 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                for (i = 0; i < a->item_list_sz; i++) {
 
                        /* Check if there is something to display */
-                       pos = i * 9;
+                       pos = i * nr_arrays;
                        if (!**(out + pos))
                                continue;
 
-                       /* Conversion B -> MB and inodes/1000 */
+                       /* Conversion B -> MiB and inodes/1000 */
                        for (k = 0; k < 2; k++) {
                                *(spmin + pos + k) /= (1024 * 1024);
                                *(spmax + pos + k) /= (1024 * 1024);
@@ -4900,12 +4899,7 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                                *(spmax + pos + 4 + k) /= 1000;
                        }
 
-                       if (DISPLAY_MOUNT(a->opt_flags)) {
-                               item_name = *(out + pos + 8);
-                       }
-                       else {
-                               item_name = *(out + pos + 7);
-                       }
+                       item_name = *(out + pos + 7);
 
                        if (draw_activity_graphs(a->g_nr, g_type, title, g_title, item_name, group,
                                                 spmin + pos, spmax + pos, out + pos, outsize + pos,
index 2e0753c5dd4476c81242f6b704ca29400b1692fc..39c89c9c3c47eb89f238ee929480799d6fe22e02 100644 (file)
@@ -2113,17 +2113,19 @@ __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab
 {
        int i;
        struct stats_filesystem *sfc;
+       char *dev_name;
 
        xprintf(tab++, "<filesystems>");
 
        for (i = 0; i < a->nr[curr]; i++) {
-
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               /* Get name to display (persistent or standard fs name, or mount point) */
+               dev_name = get_fs_name_to_display(a, flags, sfc);
+
                if (a->item_list != NULL) {
                        /* A list of devices has been entered on the command line */
-                       if (!search_list_item(a->item_list,
-                                             DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                       if (!search_list_item(a->item_list, dev_name))
                                /* Device not found */
                                continue;
                }
@@ -2137,7 +2139,7 @@ __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab
                        "Iused=\"%llu\" "
                        "Iused-percent=\"%.2f\"/>",
                        DISPLAY_MOUNT(a->opt_flags) ? "mountp" : "fsname",
-                       DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
+                       dev_name,
                        (double) sfc->f_bfree / 1024 / 1024,
                        (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
                        /* f_blocks is not zero. But test it anyway ;-) */