]> granicus.if.org Git - sysstat/commitdiff
sadf: Allow user to select filesystems to display
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 20 May 2018 14:54:25 +0000 (16:54 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 20 May 2018 14:54:25 +0000 (16:54 +0200)
Add new option "--fs=<fs_list>". It has the same meaning as for
sar. This may be especially useful for SVG output for which it is
difficult to "grep" a particular device. Using this new option makes
it possible for the user to draw graphs only for the desired
block device(s) and not for all of them.

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

index aa3ed6184c8d36b0a15c85555244796ee5074a77..92900daab8ef8008f0bf2778de52fb9eb07cc019 100644 (file)
@@ -39,8 +39,10 @@ extern unsigned int flags;
 extern unsigned int dm_major;
 extern struct sa_dlist *st_iface_list;
 extern struct sa_dlist *st_dev_list;
+extern struct sa_dlist *st_fs_list;
 extern int dlst_iface_idx;
 extern int dlst_dev_idx;
+extern int dlst_fs_idx;
 
 /*
  ***************************************************************************
@@ -2194,6 +2196,14 @@ __print_funct_t json_print_filesystem_stats(struct activity *a, int curr, int ta
        for (i = 0; i < a->nr[curr]; i++) {
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               if (dlst_fs_idx) {
+                       /* A list of devices has been entered on the command line */
+                       if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
+                                            DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                               /* Device not found */
+                               continue;
+               }
+
                if (sep) {
                        printf(",\n");
                }
index 2e7bfdbc52fc79a390a511b86ef6a917e37cfe6c..2c163c83c73861b460f47e19af2e434c761aa01a 100644 (file)
@@ -32,8 +32,10 @@ extern unsigned int flags;
 extern unsigned int dm_major;
 extern struct sa_dlist *st_iface_list;
 extern struct sa_dlist *st_dev_list;
+extern struct sa_dlist *st_fs_list;
 extern int dlst_iface_idx;
 extern int dlst_dev_idx;
+extern int dlst_fs_idx;
 
 /*
  ***************************************************************************
@@ -1505,6 +1507,14 @@ __print_funct_t raw_print_filesystem_stats(struct activity *a, char *timestr, in
        for (i = 0; i < a->nr[curr]; i++) {
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               if (dlst_fs_idx) {
+                       /* A list of devices has been entered on the command line */
+                       if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
+                                            DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_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);
                printf(" f_bfree; %llu;", sfc->f_bfree);
index 1e5b4ad275feb56f4805f29ab31e01ebebef4726..5fc1a92b985f56fdec143f9e8611ecc0ed61d072 100644 (file)
@@ -41,8 +41,10 @@ extern unsigned int flags;
 extern unsigned int dm_major;
 extern struct sa_dlist *st_iface_list;
 extern struct sa_dlist *st_dev_list;
+extern struct sa_dlist *st_fs_list;
 extern int dlst_iface_idx;
 extern int dlst_dev_idx;
+extern int dlst_fs_idx;
 
 /*
  ***************************************************************************
@@ -2914,6 +2916,14 @@ __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
        for (i = 0; i < a->nr[curr]; i++) {
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               if (dlst_fs_idx) {
+                       /* A list of devices has been entered on the command line */
+                       if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
+                                            DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                               /* Device not found */
+                               continue;
+               }
+
                render(isdb, pre, PT_USERND,
                       "%s\tMBfsfree",
                       "%s",
diff --git a/sadf.c b/sadf.c
index a975f013588e0b4384ad81ddc6c3cdabc6d41fc4..4c8ff363ec122bdffea6767ced877e96798874c1 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -78,8 +78,8 @@ struct tstamp tm_start, tm_end;
 char *args[MAX_ARGV_NR];
 
 /* Devices entered on the command line */
-struct sa_dlist *st_iface_list = NULL, *st_dev_list = NULL;
-int dlst_iface_idx = 0, dlst_dev_idx = 0;
+struct sa_dlist *st_iface_list = NULL, *st_dev_list = NULL, *st_fs_list = NULL;
+int dlst_iface_idx = 0, dlst_dev_idx = 0, dlst_fs_idx = 0;
 
 extern struct activity *act[];
 extern struct report_format *fmt[];
@@ -101,7 +101,7 @@ void usage(char *progname)
        fprintf(stderr, _("Options are:\n"
                          "[ -C ] [ -c | -d | -g | -j | -p | -r | -x ] [ -H ] [ -h ] [ -T | -t | -U ] [ -V ]\n"
                          "[ -O <opts> [,...] ] [ -P { <cpu> [,...] | ALL } ]\n"
-                         "[ --dev=<dev_list> ] [ --iface=<iface_list> ]\n"
+                         "[ --dev=<dev_list> ] [ --fs=<fs_list> ] [ --iface=<iface_list> ]\n"
                          "[ -s [ <hh:mm[:ss]> ] ] [ -e [ <hh:mm[:ss]> ] ]\n"
                          "[ -- <sar_options> ]\n"));
        exit(1);
@@ -1432,6 +1432,12 @@ int main(int argc, char **argv)
                                         &dlst_dev_idx, &opt, 6);
                }
 
+               else if (!strncmp(argv[opt], "--fs=", 5)) {
+                       /* Parse devices entered on the command line */
+                       parse_sa_devices(argv[opt], &st_fs_list,
+                                        &dlst_fs_idx, &opt, 5);
+               }
+
                else if (!strncmp(argv[opt], "--iface=", 8)) {
                        /* Parse devices entered on the command line */
                        parse_sa_devices(argv[opt], &st_iface_list,
index 527d6733625f3372df56f7b5506298dfefb1244b..366c2cee718cd03b062f7f524a8d00dddf524788 100644 (file)
@@ -41,8 +41,10 @@ extern unsigned int flags;
 extern unsigned int dm_major;
 extern struct sa_dlist *st_iface_list;
 extern struct sa_dlist *st_dev_list;
+extern struct sa_dlist *st_fs_list;
 extern int dlst_iface_idx;
 extern int dlst_dev_idx;
+extern int dlst_fs_idx;
 
 unsigned int svg_colors[] = {0x00cc00, 0xff00bf, 0x00ffff, 0xff0000,
                             0xe85f00, 0x0000ff, 0x006020, 0x7030a0,
@@ -4656,6 +4658,14 @@ __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);
 
+                       if (dlst_fs_idx) {
+                               /* A list of devices has been entered on the command line */
+                               if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
+                                                    DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                                       /* Device not found */
+                                       continue;
+                       }
+
                        /* Look for corresponding graph */
                        for (k = 0; k < svg_p->nr_max; k++) {
                                item_name = *(out + k * 9 + 7);
index 399a583c4d7aeeaeb2e9c82d27fc858d538e9390..c0cdf2f37f93eb1a051900ae981c9eeb4f5987b3 100644 (file)
@@ -39,8 +39,10 @@ extern unsigned int flags;
 extern unsigned int dm_major;
 extern struct sa_dlist *st_iface_list;
 extern struct sa_dlist *st_dev_list;
+extern struct sa_dlist *st_fs_list;
 extern int dlst_iface_idx;
 extern int dlst_dev_idx;
+extern int dlst_fs_idx;
 
 /*
  ***************************************************************************
@@ -2100,6 +2102,14 @@ __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab
 
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               if (dlst_fs_idx) {
+                       /* A list of devices has been entered on the command line */
+                       if (!search_sa_dlist(st_fs_list, dlst_fs_idx,
+                                            DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                               /* Device not found */
+                               continue;
+               }
+
                xprintf(tab, "<filesystem %s=\"%s\" "
                        "MBfsfree=\"%.0f\" "
                        "MBfsused=\"%.0f\" "