]> granicus.if.org Git - sysstat/blobdiff - svg_stats.c
Merge branch 'scop-grep-E'
[sysstat] / svg_stats.c
index 5eba53998a803b47dec5e16c12160f5990e5eb45..aea9bda0cd862e86a2c2ba037b343b13a991dda3 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * svg_stats.c: Funtions used by sadf to display statistics in SVG format.
- * (C) 2016-2018 by Sebastien GODARD (sysstat <at> orange.fr)
+ * svg_stats.c: Functions used by sadf to display statistics in SVG format.
+ * (C) 2016-2021 by Sebastien GODARD (sysstat <at> orange.fr)
  *
  ***************************************************************************
  * This program is free software; you can redistribute it and/or modify it *
 #define _(string) (string)
 #endif
 
-extern unsigned int flags;
-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,
-                            0xffff00, 0x666635, 0xd60093, 0x00bfbf,
-                            0xcc3300, 0x50040f, 0xffffbf, 0x193d55};
-#define SVG_COLORS_IDX_MASK    0x0f
+extern uint64_t flags;
+extern int palette;
+
+unsigned int svg_colors[SVG_COL_PALETTE_NR][SVG_COL_PALETTE_SIZE] =
+       {{0x00cc00, 0xff00bf, 0x00ffff, 0xff0000,       /* Default palette */
+         0xe85f00, 0x0000ff, 0x006020, 0x7030a0,
+         0xffff00, 0x666635, 0xd60093, 0x00bfbf,
+         0xcc3300, 0x50040f, 0xffffbf, 0x193d55,
+         0x000000, 0xffffff, 0x202020, 0xffff00,
+         0xffff00, 0x808080, 0xa52a2a, 0xff0000},
+
+        {0x000000, 0x1a1aff, 0x1affb2, 0xb21aff,       /* Custom color palette */
+         0x1ab2ff, 0xff1a1a, 0xffb31a, 0xb2ff1a,
+         0xefefef, 0x000000, 0x1a1aff, 0x1affb2,
+         0xb21aff, 0x1ab2ff, 0xff1a1a, 0xffb31a,
+         0xffffff, 0x000000, 0xbebebe, 0x000000,
+         0x000000, 0x000000, 0x000000, 0x000000},
+
+        {0x696969, 0xbebebe, 0x000000, 0xa9a9a9,       /* Black & white palette */
+         0x708090, 0xc0c0c0, 0x808080, 0xd3d3d3,
+         0x909090, 0x696969, 0xbebebe, 0x000000,
+         0x000000, 0xa9a9a9, 0xc0c0c0, 0x808080,
+         0xffffff, 0x000000, 0xbebebe, 0x000000,
+         0x000000, 0x000000, 0x000000, 0x000000}};
 
 /*
  ***************************************************************************
@@ -75,8 +86,8 @@ unsigned int svg_colors[] = {0x00cc00, 0xff00bf, 0x00ffff, 0xff0000,
  *             the fields in the statistics structure.
  *
  * OUT:
- * @spmin      Array containg the possible new min values for current activity.
- * @spmax      Array containg the possible new max values for current activity.
+ * @spmin      Array containing the possible new min values for current activity.
+ * @spmax      Array containing the possible new max values for current activity.
  ***************************************************************************
  */
 void save_extrema(unsigned int types_nr[], void *cs, void *ps, unsigned long long itv,
@@ -267,53 +278,6 @@ char **allocate_graph_lines(int n, int **outsize, double **spmin, double **spmax
        return out;
 }
 
-/*
- ***************************************************************************
- * Reallocate all the arrays used to save graphs data, min and max values.
- * The new size is the double of the original one.
- *
- * IN:
- * @n          Number of slots currently allocated.
- * @out                Current pointer on arrays containing the graphs data.
- * @outsize    Current pointer on array containing the size of each element
- *             in array of chars.
- * @spmin      Current pointer on array containing min values.
- * @spmax      Current pointer on array containing max values.
- *
- * OUT:
- * @out                New pointer on arrays containing the graphs data.
- * @outsize    New pointer on array containing the size of each element
- *             in array of chars.
- * @spmin      New pointer on array containing min values.
- * @spmax      New pointer on array containing max values.
- ***************************************************************************
- */
-void reallocate_all_graph_lines(int n, char ***out, int **outsize,
-                               double **spmin, double **spmax)
-{
-       char *out_p;
-       int i;
-
-       /* Reallocate all the arrays */
-       SREALLOC(*out, char *, n * sizeof(char *) * 2);
-       SREALLOC(*outsize, int, n * sizeof(int) * 2);
-       SREALLOC(*spmin, double, n * sizeof(double) * 2);
-       SREALLOC(*spmax, double, n * sizeof(double) * 2);
-
-       /* Allocate arrays of chars that will contain graphs data for the newly allocated slots */
-       for (i = 0; i < n; i++) {
-               if ((out_p = (char *) malloc(CHUNKSIZE * sizeof(char))) == NULL) {
-                       perror("malloc");
-                       exit(4);
-               }
-               *(*out + n + i) = out_p;
-               *out_p = '\0';
-               *(*outsize + n + i) = CHUNKSIZE;
-               *(*spmin + n + i) = DBL_MAX;
-               *(*spmax + n + i) = -DBL_MAX;
-       }
-}
-
 /*
  ***************************************************************************
  * Save SVG code for current graph.
@@ -442,14 +406,18 @@ void brappend(unsigned long long timetag, double offset, double value, char **ou
              int *outsize, unsigned long long dt)
 {
        char data[128];
+       unsigned long long t = 0;
 
        /* Prepare additional graph definition data */
        if ((value == 0.0) || (dt == 0))
                /* Don't draw a flat rectangle! */
                return;
+       if (dt < timetag) {
+               t = timetag -dt;
+       }
 
        snprintf(data, 128, "<rect x=\"%llu\" y=\"%.2f\" height=\"%.2f\" width=\"%llu\"/>",
-                timetag - dt, MINIMUM(offset, 100.0), MINIMUM(value, (100.0 - offset)), dt);
+                t, MINIMUM(offset, 100.0), MINIMUM(value, (100.0 - offset)), dt);
        data[127] = '\0';
 
        save_svg_data(data, out, outsize);
@@ -528,7 +496,8 @@ void recappend(unsigned long long timetag, double p_value, double value, char **
               int *outsize, int restart, unsigned long long dt,
               double *spmin, double *spmax)
 {
-       char data[128], data1[128], data2[128];
+       char data[512], data1[128], data2[128];
+       unsigned long long t = 0;
 
        /* Save min and max values */
        if (value < *spmin) {
@@ -537,18 +506,21 @@ void recappend(unsigned long long timetag, double p_value, double value, char **
        if (value > *spmax) {
                *spmax = value;
        }
+       if (dt < timetag) {
+               t = timetag -dt;
+       }
        /* Prepare additional graph definition data */
        if (restart) {
-               snprintf(data1, 128, " M%llu,%.2f", timetag - dt, p_value);
-               data1[127] = '\0';
+               snprintf(data1, sizeof(data1), " M%llu,%.2f", t, p_value);
+               data1[sizeof(data1) - 1] = '\0';
        }
        if (p_value != value) {
-               snprintf(data2, 128, " L%llu,%.2f", timetag, value);
-               data2[127] = '\0';
+               snprintf(data2, sizeof(data2), " L%llu,%.2f", timetag, value);
+               data2[sizeof(data2) - 1] = '\0';
        }
-       snprintf(data, 128, "%s L%llu,%.2f%s", restart ? data1 : "", timetag, p_value,
+       snprintf(data, sizeof(data), "%s L%llu,%.2f%s", restart ? data1 : "", timetag, p_value,
                 p_value != value ? data2 : "");
-       data[127] = '\0';
+       data[sizeof(data) - 1] = '\0';
 
        save_svg_data(data, out, outsize);
 }
@@ -633,12 +605,19 @@ void display_hgrid(double ypos, double yfactor, double lmax, int dp)
        int j = 0;
        char stmp[32];
 
+       /* Print marker in debug mode */
+       if (DISPLAY_DEBUG_MODE(flags)) {
+               printf("<!-- Hgrid -->\n");
+       }
+
        do {
                /* Display horizontal lines (except on X axis) */
                if (j > 0) {
                        printf("<polyline points=\"0,%.2f %d,%.2f\" style=\"vector-effect: non-scaling-stroke; "
-                              "stroke: #202020\" transform=\"scale(1,%f)\"/>\n",
-                              ypos * j, SVG_G_XSIZE, ypos * j, yfactor);
+                              "stroke: #%06x\" transform=\"scale(1,%f)\"/>\n",
+                              ypos * j, SVG_G_XSIZE, ypos * j,
+                              svg_colors[palette][SVG_COL_GRID_IDX],
+                              yfactor);
                }
 
                /*
@@ -647,9 +626,11 @@ void display_hgrid(double ypos, double yfactor, double lmax, int dp)
                 * to make sure they are properly aligned.
                 */
                sprintf(stmp, "%.2f", ypos * j);
-               printf("<text x=\"0\" y=\"%ld\" style=\"fill: white; stroke: none; font-size: 12px; "
+               printf("<text x=\"0\" y=\"%ld\" style=\"fill: #%06x; stroke: none; font-size: 12px; "
                       "text-anchor: end\">%.*f.</text>\n",
-                      (long) (atof(stmp) * yfactor), dp, ypos * j);
+                      (long) (atof(stmp) * yfactor),
+                      svg_colors[palette][SVG_COL_AXIS_IDX],
+                      dp, ypos * j);
                j++;
        }
        while ((ypos * j <= lmax) && (j < MAX_HLINES_NR));
@@ -676,6 +657,11 @@ void display_vgrid(long int xpos, double xfactor, int v_gridnr, struct svg_parm
 
        stamp.ust_time = svg_p->ust_time_ref; /* Only ust_time field needs to be set. TRUE_TIME not allowed */
 
+       /* Print marker in debug mode */
+       if (DISPLAY_DEBUG_MODE(flags)) {
+               printf("<!-- Vgrid -->\n");
+       }
+
        /*
         * What really matters to know when we should stop drawing vertical lines
         * is the time end. v_gridnr is only informative and used to calculate
@@ -684,32 +670,44 @@ void display_vgrid(long int xpos, double xfactor, int v_gridnr, struct svg_parm
        for (j = 0; (j <= (2 * v_gridnr)) && (stamp.ust_time <= svg_p->ust_time_end); j++) {
 
                /* Display vertical lines */
-               sa_get_record_timestamp_struct(flags, &stamp, &rectime, NULL);
+               if (sa_get_record_timestamp_struct(flags, &stamp, &rectime)) {
+#ifdef DEBUG
+                       fprintf(stderr, "%s: ust_time: %llu\n", __FUNCTION__, stamp.ust_time);
+#endif
+                       exit(1);
+               }
                set_record_timestamp_string(flags, &stamp, NULL, cur_time, TIMESTAMP_LEN, &rectime);
                printf("<polyline points=\"%ld,0 %ld,%d\" style=\"vector-effect: non-scaling-stroke; "
-                      "stroke: #202020\" transform=\"scale(%f,1)\"/>\n",
-                      xpos * j, xpos * j, -SVG_G_YSIZE, xfactor);
+                      "stroke: #%06x\" transform=\"scale(%f,1)\"/>\n",
+                      xpos * j, xpos * j, -SVG_G_YSIZE,
+                      svg_colors[palette][SVG_COL_GRID_IDX],
+                      xfactor);
                /*
                 * Display graduations.
                 * NB: We may have tm_min != 0 if we have more than 24H worth of data in one datafile.
                 * In this case, we should rather display the exact time instead of only the hour.
                 */
                if (DISPLAY_ONE_DAY(flags) && (rectime.tm_min == 0)) {
-                       printf("<text x=\"%ld\" y=\"15\" style=\"fill: white; stroke: none; font-size: 14px; "
+                       printf("<text x=\"%ld\" y=\"15\" style=\"fill: #%06x; stroke: none; font-size: 14px; "
                               "text-anchor: start\">%2d:00</text>\n",
-                              (long) (xpos * j * xfactor) - 15, rectime.tm_hour);
+                              (long) (xpos * j * xfactor) - 15,
+                              svg_colors[palette][SVG_COL_AXIS_IDX],
+                              rectime.tm_hour);
                }
                else {
-                       printf("<text x=\"%ld\" y=\"10\" style=\"fill: white; stroke: none; font-size: 12px; "
+                       printf("<text x=\"%ld\" y=\"10\" style=\"fill: #%06x; stroke: none; font-size: 12px; "
                               "text-anchor: start\" transform=\"rotate(45,%ld,0)\">%s</text>\n",
-                              (long) (xpos * j * xfactor), (long) (xpos * j * xfactor), cur_time);
+                              (long) (xpos * j * xfactor),
+                              svg_colors[palette][SVG_COL_AXIS_IDX],
+                              (long) (xpos * j * xfactor), cur_time);
                }
                stamp.ust_time += xpos;
        }
 
        if (!PRINT_LOCAL_TIME(flags)) {
-               printf("<text x=\"-10\" y=\"30\" style=\"fill: yellow; stroke: none; font-size: 12px; "
-                      "text-anchor: end\">UTC</text>\n");
+               printf("<text x=\"-10\" y=\"30\" style=\"fill: #%06x; stroke: none; font-size: 12px; "
+                      "text-anchor: end\">UTC</text>\n",
+                      svg_colors[palette][SVG_COL_INFO_IDX]);
        }
 }
 
@@ -858,7 +856,7 @@ void skip_current_view(char **out, int *pos, int group)
  * @skip_void  Set to <> 0 if graphs with no data should be skipped.
  *             This is typicallly used to not display CPU offline on the
  *             whole period.
- * @id         Current activity id.
+ * @a          Current activity structure.
  * @xid                Current activity extra id number.
  *
  * RETURNS:
@@ -868,19 +866,33 @@ void skip_current_view(char **out, int *pos, int group)
 int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[], char *item_name,
                         int group[], double *spmin, double *spmax, char **out, int *outsize,
                         struct svg_parm *svg_p, struct record_header *record_hdr, int skip_void,
-                        unsigned int id, unsigned int xid)
+                        struct activity *a, unsigned int xid)
 {
        char *out_p;
-       int i, j, dp, pos = 0, views_nr = 0, displayed = FALSE;
+       int i, j, dp, pos = 0, views_nr = 0, displayed = FALSE, palpos;
        int v_gridnr, xv, yv;
        unsigned int asfactor[16];
        long int xpos;
        double lmax, xfactor, yfactor, ypos, gmin, gmax;
        char val[32], cur_date[TIMESTAMP_LEN];
+       struct tm rectime;
+
+       /* Print activity name in debug mode */
+       if (DISPLAY_DEBUG_MODE(flags)) {
+               printf("<!-- Name: %s -->\n", a->name);
+       }
 
        /* For each view which is part of current activity */
        for (i = 0; i < g_nr; i++) {
 
+               /* Print view number in debug mode */
+               if (DISPLAY_DEBUG_MODE(flags)) {
+                       printf("<!-- View %d -->\n", i + 1);
+               }
+
+               /* Used as index in color palette */
+               palpos = (palette == SVG_BW_COL_PALETTE ? 0 : pos);
+
                /* Get global min and max value for current view */
                get_global_extrema(pos, group[i], spmin, spmax, &gmin, &gmax);
 
@@ -896,7 +908,7 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
                if (!displayed) {
                        /* Translate to proper position for current activity */
                        printf("<g id=\"g%d-%d\" transform=\"translate(0,%d)\">\n",
-                              id, xid,
+                              a->id, xid,
                               SVG_H_YSIZE +
                               SVG_C_YSIZE * (DISPLAY_TOC(flags) ? svg_p->nr_act_dispd : 0) +
                               SVG_T_YSIZE * svg_p->graph_no);
@@ -917,19 +929,23 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
                }
 
                /* Graph background */
-               printf("<rect x=\"%d\" y=\"%d\" height=\"%d\" width=\"%d\"/>\n",
-                      xv, yv, SVG_V_YSIZE, SVG_V_XSIZE);
+               printf("<rect x=\"%d\" y=\"%d\" height=\"%d\" width=\"%d\" fill=\"#%06x\"/>\n",
+                      xv, yv, SVG_V_YSIZE, SVG_V_XSIZE,
+                      svg_colors[palette][SVG_COL_BCKGRD_IDX]);
 
                /* Graph title */
-               printf("<text x=\"%d\" y=\"%d\" style=\"fill: yellow; stroke: none\">%s",
-                      xv, 20 + yv, title[i]);
+               printf("<text x=\"%d\" y=\"%d\" style=\"fill: #%06x; stroke: none\">%s",
+                      xv, 20 + yv,
+                      svg_colors[palette][SVG_COL_TITLE_IDX],
+                      title[i]);
                if (item_name) {
                        printf(" [%s]", item_name);
                }
                printf("\n");
-               printf("<tspan x=\"%d\" y=\"%d\" style=\"fill: yellow; stroke: none; font-size: 12px\">"
+               printf("<tspan x=\"%d\" y=\"%d\" style=\"fill: #%06x; stroke: none; font-size: 12px\">"
                       "(Min, Max values)</tspan>\n</text>\n",
-                      xv + 5 + SVG_M_XSIZE + SVG_G_XSIZE, yv + 25);
+                      xv + 5 + SVG_M_XSIZE + SVG_G_XSIZE, yv + 25,
+                      svg_colors[palette][SVG_COL_INFO_IDX]);
 
                /*
                 * At least two samples are needed.
@@ -938,17 +954,20 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
                if ((record_hdr->ust_time == svg_p->ust_time_first) ||
                    (*(spmin + pos) == DBL_MAX) || (*(spmax + pos) == -DBL_MIN)) {
                        /* No data found */
-                       printf("<text x=\"%d\" y=\"%d\" style=\"fill: red; stroke: none\">No data</text>\n",
-                              xv, yv + SVG_M_YSIZE);
+                       printf("<text x=\"%d\" y=\"%d\" style=\"fill: #%06x; stroke: none\">No data</text>\n",
+                              xv, yv + SVG_M_YSIZE,
+                              svg_colors[palette][SVG_COL_ERROR_IDX]);
                        skip_current_view(out, &pos, group[i]);
                        continue;
                }
 
                /* X and Y axis */
-               printf("<polyline points=\"%d,%d %d,%d %d,%d\" stroke=\"white\" stroke-width=\"2\"/>\n",
+               printf("<polyline points=\"%d,%d %d,%d %d,%d\" style=\"fill: #%06x; stroke: #%06x; stroke-width: 2\"/>\n",
                       xv + SVG_M_XSIZE, yv + SVG_M_YSIZE,
                       xv + SVG_M_XSIZE, yv + SVG_M_YSIZE + SVG_G_YSIZE,
-                      xv + SVG_M_XSIZE + SVG_G_XSIZE, yv + SVG_M_YSIZE + SVG_G_YSIZE);
+                      xv + SVG_M_XSIZE + SVG_G_XSIZE, yv + SVG_M_YSIZE + SVG_G_YSIZE,
+                      svg_colors[palette][SVG_COL_BCKGRD_IDX],
+                      svg_colors[palette][SVG_COL_AXIS_IDX]);
 
                /* Autoscaling graphs if needed */
                gr_autoscaling(asfactor, 16, group[i], g_type[i], pos, gmax, spmax);
@@ -961,7 +980,7 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
                        printf("<text x=\"%d\" y=\"%d\" style=\"fill: #%06x; stroke: none; font-size: 12px\">"
                               "%s %s(%.*f, %.*f)</text>\n",
                               xv + 5 + SVG_M_XSIZE + SVG_G_XSIZE, yv + SVG_M_YSIZE + j * 15,
-                              svg_colors[(pos + j) & SVG_COLORS_IDX_MASK], g_title[pos + j] + dp,
+                              svg_colors[palette][(palpos + j) & SVG_COLORS_IDX_MASK], g_title[pos + j] + dp,
                               asfactor[j] == 1 ? "" : val,
                               !dp * 2, *(spmin + pos + j) * asfactor[j],
                               !dp * 2, *(spmax + pos + j) * asfactor[j]);
@@ -970,18 +989,20 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
                if (DISPLAY_INFO(flags)) {
                        /* Display additional info (hostname, date) */
                        printf("<text x=\"%d\" y=\"%d\" "
-                              "style=\"fill: yellow; text-anchor: end; stroke: none; font-size: 14px\">"
+                              "style=\"fill: #%06x; text-anchor: end; stroke: none; font-size: 14px\">"
                               "%s\n",
                               xv + SVG_V_XSIZE - 5, yv + SVG_M_YSIZE + SVG_G_YSIZE,
+                              svg_colors[palette][SVG_COL_INFO_IDX],
                               svg_p->file_hdr->sa_nodename);
 
                        /* Get report date */
-                       set_report_date(localtime((const time_t *) &(svg_p->file_hdr->sa_ust_time)),
+                       set_report_date(localtime_r((const time_t *) &(svg_p->file_hdr->sa_ust_time), &rectime),
                                        cur_date, sizeof(cur_date));
                        printf("<tspan x=\"%d\" y=\"%d\" "
-                              "style=\"fill: yellow; text-anchor: end; stroke: none; font-size: 14px\">"
+                              "style=\"fill: #%06x; text-anchor: end; stroke: none; font-size: 14px\">"
                               "%s</tspan>\n</text>\n",
                               xv + SVG_V_XSIZE - 5, yv + SVG_M_YSIZE + SVG_G_YSIZE + 14,
+                              svg_colors[palette][SVG_COL_INFO_IDX],
                               cur_date);
                }
 
@@ -1032,6 +1053,11 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
                /* Display vertical lines and graduations */
                display_vgrid(xpos, xfactor, v_gridnr, svg_p);
 
+               /* Print marker in debug mode */
+               if (DISPLAY_DEBUG_MODE(flags)) {
+                       printf("<!-- Graphs -->\n");
+               }
+
                /* Draw current graphs set */
                for (j = 0; j < group[i]; j++) {
                        out_p = *(out + pos + j);
@@ -1042,14 +1068,14 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
                                       "stroke: #%06x; stroke-width: 1; fill-opacity: 0\" "
                                       "transform=\"scale(%f,%f)\"/>\n",
                                       out_p,
-                                      svg_colors[(pos + j) & SVG_COLORS_IDX_MASK],
+                                      svg_colors[palette][(palpos + j) & SVG_COLORS_IDX_MASK],
                                       xfactor,
                                       yfactor * asfactor[j]);
                        }
                        else if (*out_p) {      /* Ignore flat bars */
                                /* Bar graphs */
                                printf("<g style=\"fill: #%06x; stroke: none\" transform=\"scale(%f,%f)\">\n",
-                                      svg_colors[(pos + j) & SVG_COLORS_IDX_MASK], xfactor, yfactor);
+                                      svg_colors[palette][(palpos + j) & SVG_COLORS_IDX_MASK], xfactor, yfactor);
                                printf("%s\n", out_p);
                                printf("</g>\n");
                        }
@@ -1085,6 +1111,7 @@ int draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[],
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define CPU_ARRAY_SZ   10
 __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                    unsigned long long itv, struct record_header *record_hdr)
 {
@@ -1100,7 +1127,7 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char item_name[8];
+       char item_name[16];
        double offset, val;
        int i, j, k, pos;
 
@@ -1109,7 +1136,7 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(10 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(CPU_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -1140,7 +1167,7 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
                        scc = (struct stats_cpu *) ((char *) a->buf[curr]  + i * a->msize);
                        scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
 
-                       pos = i * 10;
+                       pos = i * CPU_ARRAY_SZ;
                        offset = 0.0;
 
                        if (i == 0) {
@@ -1308,14 +1335,14 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
                        group2[0]++;
                }
 
-               for (i = 0; (i < svg_p->nr_max) && (i < a->bitmap->b_size + 1); i++) {
+               for (i = 0; (i < a->item_list_sz) && (i < a->bitmap->b_size + 1); i++) {
 
                        /* Should current CPU (including CPU "all") be displayed? */
                        if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
                                /* No */
                                continue;
 
-                       pos = i * 10;
+                       pos = i * CPU_ARRAY_SZ;
                        if (!i) {
                                /* This is CPU "all" */
                                strcpy(item_name, "all");
@@ -1328,13 +1355,13 @@ __print_funct_t svg_print_cpu_stats(struct activity *a, int curr, int action, st
                                displayed = draw_activity_graphs(a->g_nr, g_type,
                                                                 title, g_title1, item_name, group1,
                                                                 spmin + pos, spmax + pos, out + pos, outsize + pos,
-                                                                svg_p, record_hdr, i, a->id, xid);
+                                                                svg_p, record_hdr, i, a, xid);
                        }
                        else {
                                displayed = draw_activity_graphs(a->g_nr, g_type,
                                                                 title, g_title2, item_name, group2,
                                                                 spmin + pos, spmax + pos, out + pos, outsize + pos,
-                                                                svg_p, record_hdr, i, a->id, xid);
+                                                                svg_p, record_hdr, i, a, xid);
                        }
                        if (displayed) {
                                xid++;
@@ -1402,7 +1429,7 @@ __print_funct_t svg_print_pcsw_stats(struct activity *a, int curr, int action, s
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -1464,7 +1491,7 @@ __print_funct_t svg_print_swap_stats(struct activity *a, int curr, int action, s
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -1552,7 +1579,7 @@ __print_funct_t svg_print_paging_stats(struct activity *a, int curr, int action,
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -1581,12 +1608,23 @@ __print_funct_t svg_print_io_stats(struct activity *a, int curr, int action, str
        struct stats_io
                *sic = (struct stats_io *) a->buf[curr],
                *sip = (struct stats_io *) a->buf[!curr];
-       int group[] = {3, 2};
+       int group[] = {4, 3};
        int g_type[] = {SVG_LINE_GRAPH, SVG_LINE_GRAPH};
        char *title[] = {"I/O and transfer rate statistics (1)", "I/O and transfer rate statistics (2)"};
-       char *g_title[] = {"tps", "rtps", "wtps",
-                          "bread/s", "bwrtn/s"};
-       int g_fields[] = {0, 1, 2, 3, 4};
+       char *g_title[] = {"tps", "rtps", "wtps", "dtps",
+                          "bread/s", "bwrtn/s", "bdscd/s"};
+       /*
+        * tps:0, rtps:1, wtps:2, dtps:3, bread/s:4, bwrtn/s:5, bdscd/s:6
+        * g_fields[]:
+        *      dk_drive=0
+        *      dk_drive_rio:1
+        *      dk_drive_wio:2
+        *      dk_drive_rblk:4
+        *      dk_drive_wblk:5
+        *      dk_drive_dio:3
+        *      dk_drive_dblk:6
+        */
+       int g_fields[] = {0, 1, 2, 4, 5, 3, 6};
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
@@ -1596,7 +1634,7 @@ __print_funct_t svg_print_io_stats(struct activity *a, int curr, int action, str
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(5, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(7, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -1625,21 +1663,31 @@ __print_funct_t svg_print_io_stats(struct activity *a, int curr, int action, str
                         sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
                         S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
                         out + 2, outsize + 2, svg_p->restart);
+               /* dtps */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        sic->dk_drive_dio < sip->dk_drive_dio ? 0.0 :
+                        S_VALUE(sip->dk_drive_dio, sic->dk_drive_dio, itv),
+                        out + 3, outsize + 3, svg_p->restart);
                /* bread/s */
                lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
                         S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
-                        out + 3, outsize + 3, svg_p->restart);
+                        out + 4, outsize + 4, svg_p->restart);
                /* bwrtn/s */
                lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
                         S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv),
-                        out + 4, outsize + 4, svg_p->restart);
+                        out + 5, outsize + 5, svg_p->restart);
+               /* bdscd/s */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        sic->dk_drive_dblk < sip->dk_drive_dblk ? 0.0 :
+                        S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv),
+                        out + 6, outsize + 6, svg_p->restart);
        }
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -1866,7 +1914,7 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                        if (draw_activity_graphs(DISPLAY_MEM_ALL(a->opt_flags) ? 6 : 5,
                                                 g_type1, title1, g_title1, NULL, group1,
                                                 spmin, spmax, out, outsize, svg_p, record_hdr,
-                                                FALSE, a->id, xid)) {
+                                                FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -1874,7 +1922,7 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                if (DISPLAY_SWAP(a->opt_flags)) {
                        draw_activity_graphs(3, g_type2, title2, g_title2, NULL, group2,
                                             spmin + 16, spmax + 16, out + 16, outsize + 16,
-                                            svg_p, record_hdr, FALSE, a->id, xid);
+                                            svg_p, record_hdr, FALSE, a, xid);
                }
 
                /* Free remaining structures */
@@ -1945,7 +1993,7 @@ __print_funct_t svg_print_ktables_stats(struct activity *a, int curr, int action
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -2029,7 +2077,7 @@ __print_funct_t svg_print_queue_stats(struct activity *a, int curr, int action,
                *(spmin + 5) /= 100; *(spmax + 5) /= 100;
 
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -2052,29 +2100,30 @@ __print_funct_t svg_print_queue_stats(struct activity *a, int curr, int action,
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define DISK_ARRAY_SZ  9
 __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                     unsigned long long itv, struct record_header *record_hdr)
 {
        struct stats_disk *sdc, *sdp, sdpzero;
        struct ext_disk_stats xds;
-       int group[] = {1, 2, 2, 2, 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", "svctm",
+                          "await",
                           "%util"};
        int g_fields[] = {0, 1, 2};
        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;
+       char *dev_name, *item_name;
+       double rkB, wkB, dkB, aqusz;
        int i, j, k, pos, restart, *unregistered;
 
        if (action & F_BEGIN) {
@@ -2082,23 +2131,21 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                 * Allocate arrays (#0..7) that will contain the graphs data
                 * and the min/max values.
                 * 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,
+                * out + 8 will contain the device name (WWN id, pretty name or devm-n),
                 * 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(9 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(DISK_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
                memset(&sdpzero, 0, STATS_DISK_SIZE);
-               restart = svg_p->restart;
                /*
                 * Mark previously registered devices as now
                 * possibly unregistered for all graphs.
                 */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 9 + 8;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * DISK_ARRAY_SZ + 8;
                        if (*unregistered == FALSE) {
                                *unregistered = MAYBE;
                        }
@@ -2107,38 +2154,44 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                /* For each device structure */
                for (i = 0; i < a->nr[curr]; i++) {
                        sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
+                       restart = svg_p->restart;
 
-                       /* Get device name */
-                       item_name = get_sa_devname(sdc->major, sdc->minor, flags);
+                       /* Get device name  */
+                       dev_name = get_device_name(sdc->major, sdc->minor, sdc->wwn, sdc->part_nr,
+                                                  DISPLAY_PRETTY(flags), DISPLAY_PERSIST_NAME_S(flags),
+                                                  USE_STABLE_ID(flags), NULL);
 
-                       if (dlst_dev_idx) {
+                       if (a->item_list != NULL) {
                                /* A list of devices has been entered on the command line */
-                               if (!search_sa_dlist(st_dev_list, dlst_dev_idx, item_name))
+                               if (!search_list_item(a->item_list, dev_name))
                                        /* Device not found */
                                        continue;
                        }
 
                        /* Look for corresponding graph */
-                       for (k = 0; k < svg_p->nr_max; k++) {
-                               if ((sdc->major == *(spmax + k * 9 + 8)) &&
-                                   (sdc->minor == *(spmin + k * 9 + 8)))
+                       for (k = 0; k < a->item_list_sz; k++) {
+                               item_name = *(out + k * DISK_ARRAY_SZ + 8);
+                               if (!strcmp(dev_name, item_name))
                                        /* Graph found! */
                                        break;
                        }
-                       if (k == svg_p->nr_max) {
+                       if (k == a->item_list_sz) {
                                /* Graph not found: Look for first free entry */
-                               for (k = 0; k < svg_p->nr_max; k++) {
-                                       if (*(spmax + k * 9 + 8) == -DBL_MAX)
+                               for (k = 0; k < a->item_list_sz; k++) {
+                                       item_name = *(out + k * DISK_ARRAY_SZ + 8);
+                                       if (!strcmp(item_name, ""))
                                                break;
                                }
-                               if (k == svg_p->nr_max) {
-                                       /* No free graph entry: Extend all buffers */
-                                       reallocate_all_graph_lines(9 * svg_p->nr_max,
-                                                                  &out, &outsize, &spmin, &spmax);
-                                       svg_p->nr_max *= 2;
+                               if (k == a->item_list_sz) {
+                                       /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+                                       fprintf(stderr, "%s: Name=%s major=%d minor=%d\n",
+                                               __FUNCTION__, dev_name, sdc->major, sdc->minor);
+#endif
+                                       continue;
                                }
                        }
-                       pos = k * 9;
+                       pos = k * DISK_ARRAY_SZ;
                        unregistered = outsize + pos + 8;
 
                        /*
@@ -2151,16 +2204,18 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                        }
                        *unregistered = FALSE;
 
-                       if (*(spmax + pos + 8) == -DBL_MAX) {
-                               /* Save device major and minor numbers (if not already done) */
-                               *(spmax + pos + 8) = sdc->major;
-                               *(spmin + pos + 8) = sdc->minor;
+                       item_name = *(out + pos + 8);
+                       if (!item_name[0]) {
+                               /* Save device name (WWN id or pretty name) if not already done */
+                               strncpy(item_name, dev_name, CHUNKSIZE);
+                               item_name[CHUNKSIZE - 1] = '\0';
                        }
 
                        j = check_disk_reg(a, curr, !curr, i);
                        if (j < 0) {
                                /* This is a newly registered interface. Previous stats are zero */
                                sdp = &sdpzero;
+                               restart = TRUE;
                        }
                        else {
                                sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
@@ -2172,6 +2227,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;
                        }
@@ -2184,32 +2240,32 @@ __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 > *(spmax + pos + 4)) {
-                               *(spmax + pos + 4) = aqusz;
-                       }
-                       if (xds.await < *(spmin + pos + 5)) {
-                               *(spmin + pos + 5) = xds.await;
+                       if (aqusz < *(spmin + pos + 5)) {
+                               *(spmin + pos + 5) = aqusz;
                        }
-                       if (xds.await > *(spmax + pos + 5)) {
-                               *(spmax + pos + 5) = xds.await;
+                       if (aqusz > *(spmax + pos + 5)) {
+                               *(spmax + pos + 5) = aqusz;
                        }
-                       if (xds.svctm < *(spmin + pos + 6)) {
-                               *(spmin + pos + 6) = xds.svctm;
+                       if (xds.await < *(spmin + pos + 6)) {
+                               *(spmin + pos + 6) = xds.await;
                        }
-                       if (xds.svctm > *(spmax + pos + 6)) {
-                               *(spmax + pos + 6) = xds.svctm;
+                       if (xds.await > *(spmax + pos + 6)) {
+                               *(spmax + pos + 6) = xds.await;
                        }
                        if ((xds.util / 10.0) < *(spmin + pos + 7)) {
                                *(spmin + pos + 7) = xds.util / 10.0;
@@ -2230,21 +2286,21 @@ __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->dc_sect, sdc->dc_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);
-                       /* svctm */
-                       lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
-                                xds.svctm,
                                 out + pos + 6, outsize + pos + 6, restart);
                        /* %util */
                        brappend(record_hdr->ust_time - svg_p->ust_time_ref,
@@ -2253,8 +2309,8 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                }
 
                /* Mark devices not seen here as now unregistered */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 9 + 8;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * DISK_ARRAY_SZ + 8;
                        if (*unregistered != FALSE) {
                                *unregistered = TRUE;
                        }
@@ -2264,19 +2320,17 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
                        /* Check if there is something to display */
-                       pos = i * 9;
+                       pos = i * DISK_ARRAY_SZ;
                        if (!**(out + pos))
                                continue;
 
-                       /* Get device name */
-                       item_name = get_sa_devname(*(spmax + pos + 8), *(spmin + pos + 8), flags);
-
+                       item_name = *(out + pos + 8);
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
                                                 spmin + pos, spmax + pos, out + pos, outsize + pos,
-                                                svg_p, record_hdr, FALSE, a->id, xid)) {
+                                                svg_p, record_hdr, FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -2302,6 +2356,7 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define NET_DEV_ARRAY_SZ       9
 __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                        unsigned long long itv, struct record_header *record_hdr)
 {
@@ -2333,18 +2388,17 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action
                 * outsize + 8 will contain a positive value (TRUE) if the interface
                 * has either still not been registered, or has been unregistered.
                 */
-               out = allocate_graph_lines(9 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(NET_DEV_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
                memset(&sndzero, 0, STATS_NET_DEV_SIZE);
-               restart = svg_p->restart;
                /*
                 * Mark previously registered interfaces as now
                 * possibly unregistered for all graphs.
                 */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 9 + 8;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * NET_DEV_ARRAY_SZ + 8;
                        if (*unregistered == FALSE) {
                                *unregistered = MAYBE;
                        }
@@ -2353,42 +2407,46 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action
                /* For each network interfaces structure */
                for (i = 0; i < a->nr[curr]; i++) {
                        sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
+                       restart = svg_p->restart;
 
-                       if (dlst_iface_idx) {
+                       if (a->item_list != NULL) {
                                /* A list of devices has been entered on the command line */
-                               if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
+                               if (!search_list_item(a->item_list, sndc->interface))
                                        /* Device not found */
                                        continue;
                        }
 
                        /* Look for corresponding graph */
-                       for (k = 0; k < svg_p->nr_max; k++) {
-                               item_name = *(out + k * 9 + 8);
+                       for (k = 0; k < a->item_list_sz; k++) {
+                               item_name = *(out + k * NET_DEV_ARRAY_SZ + 8);
                                if (!strcmp(sndc->interface, item_name))
                                        /* Graph found! */
                                        break;
                        }
-                       if (k == svg_p->nr_max) {
+                       if (k == a->item_list_sz) {
                                /* Graph not found: Look for first free entry */
-                               for (k = 0; k < svg_p->nr_max; k++) {
-                                       item_name = *(out + k * 9 + 8);
+                               for (k = 0; k < a->item_list_sz; k++) {
+                                       item_name = *(out + k * NET_DEV_ARRAY_SZ + 8);
                                        if (!strcmp(item_name, ""))
                                                break;
                                }
-                               if (k == svg_p->nr_max) {
-                                       /* No free graph entry: Extend all buffers */
-                                       reallocate_all_graph_lines(9 * svg_p->nr_max,
-                                                                  &out, &outsize, &spmin, &spmax);
-                                       svg_p->nr_max *= 2;
+                               if (k == a->item_list_sz) {
+                                       /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+                                       fprintf(stderr, "%s: Name=%s\n",
+                                               __FUNCTION__, sndc->interface);
+#endif
+                                       continue;
                                }
                        }
-                       pos = k * 9;
+                       pos = k * NET_DEV_ARRAY_SZ;
                        unregistered = outsize + pos + 8;
 
                        j = check_net_dev_reg(a, curr, !curr, i);
                        if (j < 0) {
                                /* This is a newly registered interface. Previous stats are zero */
                                sndp = &sndzero;
+                               restart = TRUE;
                        }
                        else {
                                sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
@@ -2460,8 +2518,8 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action
                }
 
                /* Mark interfaces not seen here as now unregistered */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 9 + 8;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * NET_DEV_ARRAY_SZ + 8;
                        if (*unregistered != FALSE) {
                                *unregistered = TRUE;
                        }
@@ -2471,13 +2529,13 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
                        /*
                         * Check if there is something to display.
                         * Don't test sndc->interface because maybe the network
                         * interface has been registered later.
                         */
-                       pos = i * 9;
+                       pos = i * NET_DEV_ARRAY_SZ;
                        if (!**(out + pos))
                                continue;
 
@@ -2491,7 +2549,7 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
                                                 spmin + pos, spmax + pos, out + pos, outsize + pos,
-                                                svg_p, record_hdr, FALSE, a->id, xid)) {
+                                                svg_p, record_hdr, FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -2517,6 +2575,7 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define NET_EDEV_ARRAY_SZ      10
 __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                         unsigned long long itv, struct record_header *record_hdr)
 {
@@ -2546,18 +2605,17 @@ __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int actio
                 * outsize + 9 will contain a positive value (TRUE) if the interface
                 * has either still not been registered, or has been unregistered.
                 */
-               out = allocate_graph_lines(10 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(NET_EDEV_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
                memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
-               restart = svg_p->restart;
                /*
                 * Mark previously registered interfaces as now
                 * possibly unregistered for all graphs.
                 */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 10 + 9;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * NET_EDEV_ARRAY_SZ + 9;
                        if (*unregistered == FALSE) {
                                *unregistered = MAYBE;
                        }
@@ -2566,46 +2624,47 @@ __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int actio
                /* For each network interfaces structure */
                for (i = 0; i < a->nr[curr]; i++) {
                        snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
-                       if (!strcmp(snedc->interface, ""))
-                               /* Empty structure: This is the end of the list */
-                               break;
+                       restart = svg_p->restart;
 
-                       if (dlst_iface_idx) {
+                       if (a->item_list != NULL) {
                                /* A list of devices has been entered on the command line */
-                               if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
+                               if (!search_list_item(a->item_list, snedc->interface))
                                        /* Device not found */
                                        continue;
                        }
 
                        /* Look for corresponding graph */
-                       for (k = 0; k < svg_p->nr_max; k++) {
-                               item_name = *(out + k * 10 + 9);
+                       for (k = 0; k < a->item_list_sz; k++) {
+                               item_name = *(out + k * NET_EDEV_ARRAY_SZ + 9);
                                if (!strcmp(snedc->interface, item_name))
                                        /* Graph found! */
                                        break;
                        }
-                       if (k == svg_p->nr_max) {
+                       if (k == a->item_list_sz) {
                                /* Graph not found: Look for first free entry */
-                               for (k = 0; k < svg_p->nr_max; k++) {
-                                       item_name = *(out + k * 10 + 9);
+                               for (k = 0; k < a->item_list_sz; k++) {
+                                       item_name = *(out + k * NET_EDEV_ARRAY_SZ + 9);
                                        if (!strcmp(item_name, ""))
                                                break;
                                }
-                               if (k == svg_p->nr_max) {
-                                       /* No free graph entry: Extend all buffers */
-                                       reallocate_all_graph_lines(10 * svg_p->nr_max,
-                                                                  &out, &outsize, &spmin, &spmax);
-                                       svg_p->nr_max *= 2;
+                               if (k == a->item_list_sz) {
+                                       /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+                                       fprintf(stderr, "%s: Name=%s\n",
+                                               __FUNCTION__, snedc->interface);
+#endif
+                                       continue;
                                }
                        }
 
-                       pos = k * 10;
+                       pos = k * NET_EDEV_ARRAY_SZ;
                        unregistered = outsize + pos + 9;
 
                        j = check_net_edev_reg(a, curr, !curr, i);
                        if (j < 0) {
                                /* This is a newly registered interface. Previous stats are zero */
                                snedp = &snedzero;
+                               restart = TRUE;
                        }
                        else {
                                snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
@@ -2671,8 +2730,8 @@ __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int actio
                }
 
                /* Mark interfaces not seen here as now unregistered */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 10 + 9;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * NET_EDEV_ARRAY_SZ + 9;
                        if (*unregistered != FALSE) {
                                *unregistered = TRUE;
                        }
@@ -2682,13 +2741,13 @@ __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int actio
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
                        /*
                         * Check if there is something to display.
                         * Don't test snedc->interface because maybe the network
                         * interface has been registered later.
                         */
-                       pos = i * 10;
+                       pos = i * NET_EDEV_ARRAY_SZ;
                        if (!**(out + pos))
                                continue;
 
@@ -2696,7 +2755,7 @@ __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int actio
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
                                                 spmin + pos, spmax + pos, out + pos, outsize + pos,
-                                                svg_p, record_hdr, FALSE, a->id, xid)) {
+                                                svg_p, record_hdr, FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -2781,7 +2840,7 @@ __print_funct_t svg_print_net_nfs_stats(struct activity *a, int curr, int action
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -2887,7 +2946,7 @@ __print_funct_t svg_print_net_nfsd_stats(struct activity *a, int curr, int actio
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -2965,7 +3024,7 @@ __print_funct_t svg_print_net_sock_stats(struct activity *a, int curr, int actio
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3054,7 +3113,7 @@ __print_funct_t svg_print_net_ip_stats(struct activity *a, int curr, int action,
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3144,7 +3203,7 @@ __print_funct_t svg_print_net_eip_stats(struct activity *a, int curr, int action
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3260,7 +3319,7 @@ __print_funct_t svg_print_net_icmp_stats(struct activity *a, int curr, int actio
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3371,7 +3430,7 @@ __print_funct_t svg_print_net_eicmp_stats(struct activity *a, int curr, int acti
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3443,7 +3502,7 @@ __print_funct_t svg_print_net_tcp_stats(struct activity *a, int curr, int action
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3519,7 +3578,7 @@ __print_funct_t svg_print_net_etcp_stats(struct activity *a, int curr, int actio
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3591,7 +3650,7 @@ __print_funct_t svg_print_net_udp_stats(struct activity *a, int curr, int action
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3660,7 +3719,7 @@ __print_funct_t svg_print_net_sock6_stats(struct activity *a, int curr, int acti
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3760,7 +3819,7 @@ __print_funct_t svg_print_net_ip6_stats(struct activity *a, int curr, int action
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3865,7 +3924,7 @@ __print_funct_t svg_print_net_eip6_stats(struct activity *a, int curr, int actio
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -3995,7 +4054,7 @@ __print_funct_t svg_print_net_icmp6_stats(struct activity *a, int curr, int acti
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -4102,7 +4161,7 @@ __print_funct_t svg_print_net_eicmp6_stats(struct activity *a, int curr, int act
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -4174,7 +4233,7 @@ __print_funct_t svg_print_net_udp6_stats(struct activity *a, int curr, int actio
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -4208,7 +4267,7 @@ __print_funct_t svg_print_pwr_cpufreq_stats(struct activity *a, int curr, int ac
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char item_name[8];
+       char item_name[16];
        int i;
 
        if (action & F_BEGIN) {
@@ -4216,7 +4275,7 @@ __print_funct_t svg_print_pwr_cpufreq_stats(struct activity *a, int curr, int ac
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -4248,7 +4307,7 @@ __print_funct_t svg_print_pwr_cpufreq_stats(struct activity *a, int curr, int ac
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; (i < svg_p->nr_max) && (i < a->bitmap->b_size + 1); i++) {
+               for (i = 0; (i < a->item_list_sz) && (i < a->bitmap->b_size + 1); i++) {
 
                        /* Should current CPU (including CPU "all") be displayed? */
                        if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
@@ -4274,7 +4333,7 @@ __print_funct_t svg_print_pwr_cpufreq_stats(struct activity *a, int curr, int ac
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
                                                 spmin + i, spmax + i, out + i, outsize + i,
-                                                svg_p, record_hdr, i, a->id, xid)) {
+                                                svg_p, record_hdr, i, a, xid)) {
                                xid++;
                        }
                }
@@ -4311,7 +4370,7 @@ __print_funct_t svg_print_pwr_fan_stats(struct activity *a, int curr, int action
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char item_name[MAX_SENSORS_DEV_LEN + 8];
+       char item_name[MAX_SENSORS_DEV_LEN + 16];
        int i;
 
        if (action & F_BEGIN) {
@@ -4319,7 +4378,7 @@ __print_funct_t svg_print_pwr_fan_stats(struct activity *a, int curr, int action
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -4341,17 +4400,17 @@ __print_funct_t svg_print_pwr_fan_stats(struct activity *a, int curr, int action
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
 
                        spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
 
-                       snprintf(item_name, MAX_SENSORS_DEV_LEN + 8, "%d: %s", i + 1, spc->device);
-                       item_name[MAX_SENSORS_DEV_LEN + 7] = '\0';
+                       snprintf(item_name, sizeof(item_name), "%d: %s", i + 1, spc->device);
+                       item_name[sizeof(item_name) - 1] = '\0';
 
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
                                                 spmin + i, spmax + i, out + i, outsize + i,
-                                                svg_p, record_hdr, FALSE, a->id, xid)) {
+                                                svg_p, record_hdr, FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -4377,6 +4436,7 @@ __print_funct_t svg_print_pwr_fan_stats(struct activity *a, int curr, int action
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define TEMP_ARRAY_SZ  2
 __print_funct_t svg_print_pwr_temp_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                         unsigned long long itv, struct record_header *record_hdr)
 {
@@ -4390,7 +4450,7 @@ __print_funct_t svg_print_pwr_temp_stats(struct activity *a, int curr, int actio
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char item_name[MAX_SENSORS_DEV_LEN + 8];
+       char item_name[MAX_SENSORS_DEV_LEN + 16];
        int i;
        double tval;
 
@@ -4399,7 +4459,7 @@ __print_funct_t svg_print_pwr_temp_stats(struct activity *a, int curr, int actio
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(2 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(TEMP_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -4409,47 +4469,48 @@ __print_funct_t svg_print_pwr_temp_stats(struct activity *a, int curr, int actio
                        spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
 
                        /* Look for min/max values */
-                       if (spc->temp < *(spmin + 2 * i)) {
-                               *(spmin + 2 * i) = spc->temp;
+                       if (spc->temp < *(spmin + TEMP_ARRAY_SZ * i)) {
+                               *(spmin + TEMP_ARRAY_SZ * i) = spc->temp;
                        }
-                       if (spc->temp > *(spmax + 2 * i)) {
-                               *(spmax + 2 * i) = spc->temp;
+                       if (spc->temp > *(spmax + TEMP_ARRAY_SZ * i)) {
+                               *(spmax + TEMP_ARRAY_SZ * i) = spc->temp;
                        }
                        tval = (spc->temp_max - spc->temp_min) ?
                               (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
                               0.0;
-                       if (tval < *(spmin + 2 * i + 1)) {
-                               *(spmin + 2 * i + 1) = tval;
+                       if (tval < *(spmin + TEMP_ARRAY_SZ * i + 1)) {
+                               *(spmin + TEMP_ARRAY_SZ * i + 1) = tval;
                        }
-                       if (tval > *(spmax + 2 * i + 1)) {
-                               *(spmax + 2 * i + 1) = tval;
+                       if (tval > *(spmax + TEMP_ARRAY_SZ * i + 1)) {
+                               *(spmax + TEMP_ARRAY_SZ * i + 1) = tval;
                        }
 
                        /* degC */
                        lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 (double) spc->temp,
-                                out + 2 * i, outsize + 2 * i, svg_p->restart);
+                                out + TEMP_ARRAY_SZ * i, outsize + TEMP_ARRAY_SZ * i, svg_p->restart);
                        /* %temp */
                        brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 0.0, tval,
-                                out + 2 * i + 1, outsize + 2 * i + 1, svg_p->dt);
+                                out + TEMP_ARRAY_SZ * i + 1, outsize + TEMP_ARRAY_SZ * i + 1, svg_p->dt);
                }
        }
 
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
 
                        spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
 
-                       snprintf(item_name, MAX_SENSORS_DEV_LEN + 8, "%d: %s", i + 1, spc->device);
-                       item_name[MAX_SENSORS_DEV_LEN + 7] = '\0';
+                       snprintf(item_name, sizeof(item_name), "%d: %s", i + 1, spc->device);
+                       item_name[sizeof(item_name) - 1] = '\0';
 
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
-                                                spmin + 2 * i, spmax + 2 * i, out + 2 * i, outsize + 2 * i,
-                                                svg_p, record_hdr, FALSE, a->id, xid)) {
+                                                spmin + TEMP_ARRAY_SZ * i, spmax + TEMP_ARRAY_SZ * i,
+                                                out + TEMP_ARRAY_SZ * i, outsize + TEMP_ARRAY_SZ * i,
+                                                svg_p, record_hdr, FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -4475,6 +4536,7 @@ __print_funct_t svg_print_pwr_temp_stats(struct activity *a, int curr, int actio
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define IN_ARRAY_SZ    2
 __print_funct_t svg_print_pwr_in_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                       unsigned long long itv, struct record_header *record_hdr)
 {
@@ -4488,7 +4550,7 @@ __print_funct_t svg_print_pwr_in_stats(struct activity *a, int curr, int action,
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char item_name[MAX_SENSORS_DEV_LEN + 8];
+       char item_name[MAX_SENSORS_DEV_LEN + 16];
        int i;
        double tval;
 
@@ -4497,7 +4559,7 @@ __print_funct_t svg_print_pwr_in_stats(struct activity *a, int curr, int action,
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(2 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(IN_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -4507,47 +4569,48 @@ __print_funct_t svg_print_pwr_in_stats(struct activity *a, int curr, int action,
                        spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
 
                        /* Look for min/max values */
-                       if (spc->in < *(spmin + 2 * i)) {
-                               *(spmin + 2 * i) = spc->in;
+                       if (spc->in < *(spmin + IN_ARRAY_SZ * i)) {
+                               *(spmin + IN_ARRAY_SZ * i) = spc->in;
                        }
-                       if (spc->in > *(spmax + 2 * i)) {
-                               *(spmax + 2 * i) = spc->in;
+                       if (spc->in > *(spmax + IN_ARRAY_SZ * i)) {
+                               *(spmax + IN_ARRAY_SZ * i) = spc->in;
                        }
                        tval = (spc->in_max - spc->in_min) ?
                               (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
                               0.0;
-                       if (tval < *(spmin + 2 * i + 1)) {
-                               *(spmin + 2 * i + 1) = tval;
+                       if (tval < *(spmin + IN_ARRAY_SZ * i + 1)) {
+                               *(spmin + IN_ARRAY_SZ * i + 1) = tval;
                        }
-                       if (tval > *(spmax + 2 * i + 1)) {
-                               *(spmax + 2 * i + 1) = tval;
+                       if (tval > *(spmax + IN_ARRAY_SZ * i + 1)) {
+                               *(spmax + IN_ARRAY_SZ * i + 1) = tval;
                        }
 
                        /* inV */
                        lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 (double) spc->in,
-                                out + 2 * i, outsize + 2 * i, svg_p->restart);
+                                out + IN_ARRAY_SZ * i, outsize + IN_ARRAY_SZ * i, svg_p->restart);
                        /* %in */
                        brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                                 0.0, tval,
-                                out + 2 * i + 1, outsize + 2 * i + 1, svg_p->dt);
+                                out + IN_ARRAY_SZ * i + 1, outsize + IN_ARRAY_SZ * i + 1, svg_p->dt);
                }
        }
 
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
 
                        spc = (struct stats_pwr_in *) ((char *) a->buf[curr]  + i * a->msize);
 
-                       snprintf(item_name, MAX_SENSORS_DEV_LEN + 8, "%d: %s", i + 1, spc->device);
-                       item_name[MAX_SENSORS_DEV_LEN + 7] = '\0';
+                       snprintf(item_name, sizeof(item_name), "%d: %s", i + 1, spc->device);
+                       item_name[sizeof(item_name) - 1] = '\0';
 
                        if (draw_activity_graphs(a->g_nr, g_type,
                                                 title, g_title, item_name, group,
-                                                spmin + 2 * i, spmax + 2 * i, out + 2 * i, outsize + 2 * i,
-                                                svg_p, record_hdr, FALSE, a->id, xid)) {
+                                                spmin + IN_ARRAY_SZ * i, spmax + IN_ARRAY_SZ * i,
+                                                out + IN_ARRAY_SZ * i, outsize + IN_ARRAY_SZ * i,
+                                                svg_p, record_hdr, FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -4578,14 +4641,13 @@ __print_funct_t svg_print_huge_stats(struct activity *a, int curr, int action, s
 {
        struct stats_huge
                *smc = (struct stats_huge *) a->buf[curr];
-       int group[] = {2, 1};
+       int group[] = {4, 1};
        int g_type[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH};
        char *title[] = {"Huge pages utilization (1)",
                         "Huge pages utilization (2)"};
-       char *g_title[] = {"~kbhugfree", "~kbhugused",
+       char *g_title[] = {"~kbhugfree", "~kbhugused", "~kbhugrsvd", "~kbhugsurp",
                           "%hugused"};
-       int g_fields[] = {0};
-       unsigned int local_types_nr[] = {0, 1, 0};
+       int g_fields[] = {0, 5, 2, 3};
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
@@ -4595,13 +4657,15 @@ __print_funct_t svg_print_huge_stats(struct activity *a, int curr, int action, s
                /*
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
+                * Allocate one additional array (#5) to save min/max
+                * values for tlhkb (unused).
                 */
-               out = allocate_graph_lines(3, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(6, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
                /* Check for min/max values */
-               save_extrema(local_types_nr, (void *) a->buf[curr], NULL,
+               save_extrema(a->gtypes_nr, (void *) a->buf[curr], NULL,
                             itv, spmin, spmax, g_fields);
 
                if (smc->tlhkb - smc->frhkb < *(spmin + 1)) {
@@ -4611,11 +4675,11 @@ __print_funct_t svg_print_huge_stats(struct activity *a, int curr, int action, s
                        *(spmax + 1) = smc->tlhkb - smc->frhkb;
                }
                tval = smc->tlhkb ? SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0;
-               if (tval < *(spmin + 2)) {
-                       *(spmin + 2) = tval;
+               if (tval < *(spmin + 4)) {
+                       *(spmin + 4) = tval;
                }
-               if (tval > *(spmax + 2)) {
-                       *(spmax + 2) = tval;
+               if (tval > *(spmax + 4)) {
+                       *(spmax + 4) = tval;
                }
 
                /* kbhugfree */
@@ -4626,16 +4690,24 @@ __print_funct_t svg_print_huge_stats(struct activity *a, int curr, int action, s
                lniappend(record_hdr->ust_time - svg_p->ust_time_ref,
                          (unsigned long long) smc->tlhkb - smc->frhkb,
                          out + 1, outsize + 1, svg_p->restart);
+               /* kbhugrsvd */
+               lniappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                         (unsigned long long) smc->rsvdhkb,
+                         out + 2, outsize + 2, svg_p->restart);
+               /* kbhugsurp */
+               lniappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                         (unsigned long long) smc->surphkb,
+                         out + 3, outsize + 3, svg_p->restart);
                /* %hugused */
                brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         0.0, tval,
-                        out + 2, outsize + 2, svg_p->dt);
+                        out + 4, outsize + 4, svg_p->dt);
        }
 
        if (action & F_END) {
                draw_activity_graphs(a->g_nr, g_type,
                                     title, g_title, NULL, group,
-                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a->id, 0);
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
@@ -4658,6 +4730,7 @@ __print_funct_t svg_print_huge_stats(struct activity *a, int curr, int action, s
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define FS_ARRAY_SZ    8
 __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                           unsigned long long itv, struct record_header *record_hdr)
 {
@@ -4674,7 +4747,7 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
        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;
 
@@ -4682,11 +4755,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 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(FS_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -4694,46 +4766,47 @@ __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) {
+                       /* 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_sa_dlist(st_fs_list, dlst_fs_idx,
-                                                    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 < svg_p->nr_max; k++) {
-                               item_name = *(out + k * 9 + 7);
-                               if (!strcmp(sfc->fs_name, item_name))
+                       for (k = 0; k < a->item_list_sz; k++) {
+                               item_name = *(out + k * FS_ARRAY_SZ + 7);
+                               if (!strcmp(dev_name, item_name))
                                        /* Graph found! */
                                        break;
                        }
 
-                       if (k == svg_p->nr_max) {
+                       if (k == a->item_list_sz) {
                                /* Graph not found: Look for first free entry */
-                               for (k = 0; k < svg_p->nr_max; k++) {
-                                       item_name = *(out + k * 9 + 7);
+                               for (k = 0; k < a->item_list_sz; k++) {
+                                       item_name = *(out + k * FS_ARRAY_SZ + 7);
                                        if (!strcmp(item_name, ""))
                                                break;
                                }
-                               if (k == svg_p->nr_max) {
-                                       /* No free graph entry: Extend all buffers */
-                                       reallocate_all_graph_lines(9 * svg_p->nr_max,
-                                                                  &out, &outsize, &spmin, &spmax);
-                                       svg_p->nr_max *= 2;
+                               if (k == a->item_list_sz) {
+                                       /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+                                       fprintf(stderr, "%s: Name=%s\n",
+                                               __FUNCTION__, sfc->fs_name);
+#endif
+                                       continue;
                                }
                        }
 
-                       pos = k * 9;
+                       pos = k * FS_ARRAY_SZ;
 
                        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';
                        }
 
@@ -4848,14 +4921,14 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
        if (action & F_END) {
                int xid = 0;
 
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
 
                        /* Check if there is something to display */
-                       pos = i * 9;
+                       pos = i * FS_ARRAY_SZ;
                        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);
@@ -4863,16 +4936,11 @@ __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,
-                                                svg_p, record_hdr, FALSE, a->id, xid)) {
+                                                svg_p, record_hdr, FALSE, a, xid)) {
                                xid++;
                        }
                }
@@ -4898,10 +4966,11 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define FC_ARRAY_SZ    5
 __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                       unsigned long long itv, struct record_header *record_hdr)
 {
-       struct stats_fchost *sfcc, *sfcp;
+       struct stats_fchost *sfcc, *sfcp, sfczero;
        int group[] = {2, 2};
        int g_type[] = {SVG_LINE_GRAPH, SVG_LINE_GRAPH};
        char *title[] = {"Fibre Channel HBA statistics (1)", "Fibre Channel HBA statistics (2)"};
@@ -4923,17 +4992,17 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
                 * has either still not been registered, or has been unregistered
                 * (outsize + 4).
                 */
-               out = allocate_graph_lines(5 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(FC_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
-               restart = svg_p->restart;
+               memset(&sfczero, 0, sizeof(struct stats_fchost));
                /*
                 * Mark previously registered interfaces as now
                 * possibly unregistered for all graphs.
                 */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 5 + 4;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * FC_ARRAY_SZ + 4;
                        if (*unregistered == FALSE) {
                                *unregistered = MAYBE;
                        }
@@ -4943,35 +5012,37 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
                for (i = 0; i < a->nr[curr]; i++) {
 
                        found = FALSE;
+                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+                       restart = svg_p->restart;
 
-                       if (a->nr[!curr] > 0) {
-                               sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
-
-                               /* Look for corresponding graph */
-                               for (k = 0; k < svg_p->nr_max; k++) {
-                                       item_name = *(out + k * 5 + 4);
-                                       if (!strcmp(sfcc->fchost_name, item_name))
-                                               /* Graph found! */
+                       /* Look for corresponding graph */
+                       for (k = 0; k < a->item_list_sz; k++) {
+                               item_name = *(out + k * FC_ARRAY_SZ + 4);
+                               if (!strcmp(sfcc->fchost_name, item_name))
+                                       /* 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++) {
+                                       item_name = *(out + k * FC_ARRAY_SZ + 4);
+                                       if (!strcmp(item_name, ""))
                                                break;
                                }
-                               if (k == svg_p->nr_max) {
-                                       /* Graph not found: Look for first free entry */
-                                       for (k = 0; k < svg_p->nr_max; k++) {
-                                               item_name = *(out + k * 5 + 4);
-                                               if (!strcmp(item_name, ""))
-                                                       break;
-                                       }
-                                       if (k == svg_p->nr_max) {
-                                               /* No free graph entry: Extend all buffers */
-                                               reallocate_all_graph_lines(5 * svg_p->nr_max,
-                                                                          &out, &outsize, &spmin, &spmax);
-                                               svg_p->nr_max *= 2;
-                                       }
+                               if (k == a->item_list_sz) {
+                                       /* No free graph entry: Ignore it (should never happen) */
+#ifdef DEBUG
+                                       fprintf(stderr, "%s: Name=%s\n",
+                                               __FUNCTION__, sfcc->fchost_name);
+#endif
+                                       continue;
                                }
+                       }
 
-                               pos = k * 5;
-                               unregistered = outsize + pos + 4;
+                       pos = k * FC_ARRAY_SZ;
+                       unregistered = outsize + pos + 4;
 
+                       if (a->nr[!curr] > 0) {
                                /* Look for corresponding structure in previous iteration */
                                j = i;
 
@@ -4994,8 +5065,11 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
                                while (j != j0);
                        }
 
-                       if (!found)
-                               continue;
+                       if (!found) {
+                               /* This is a newly registered host */
+                               sfcp = &sfczero;
+                               restart = TRUE;
+                       }
 
                        /*
                         * If current interface was marked as previously unregistered,
@@ -5037,8 +5111,8 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
                }
 
                /* Mark interfaces not seen here as now unregistered */
-               for (k = 0; k < svg_p->nr_max; k++) {
-                       unregistered = outsize + k * 5 + 4;
+               for (k = 0; k < a->item_list_sz; k++) {
+                       unregistered = outsize + k * FC_ARRAY_SZ + 4;
                        if (*unregistered != FALSE) {
                                *unregistered = TRUE;
                        }
@@ -5046,10 +5120,10 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
        }
 
        if (action & F_END) {
-               for (i = 0; i < svg_p->nr_max; i++) {
+               for (i = 0; i < a->item_list_sz; i++) {
 
                        /* Check if there is something to display */
-                       pos = i * 5;
+                       pos = i * FC_ARRAY_SZ;
                        if (!**(out + pos))
                                continue;
 
@@ -5057,7 +5131,7 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
                        draw_activity_graphs(a->g_nr, g_type,
                                             title, g_title, item_name, group,
                                             spmin + pos, spmax + pos, out + pos, outsize + pos,
-                                            svg_p, record_hdr, FALSE, a->id, i);
+                                            svg_p, record_hdr, FALSE, a, i);
                }
 
                /* Free remaining structures */
@@ -5081,6 +5155,7 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
  * @record_hdr Pointer on record header of current stats sample.
  ***************************************************************************
  */
+#define SOFT_ARRAY_SZ  5
 __print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
                                        unsigned long long itv, struct record_header *record_hdr)
 {
@@ -5095,7 +5170,7 @@ __print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char item_name[8];
+       char item_name[16];
        unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
        int i, pos, restart;
 
@@ -5104,7 +5179,7 @@ __print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(5 * svg_p->nr_max, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(SOFT_ARRAY_SZ * a->item_list_sz, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -5147,7 +5222,7 @@ __print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action
                                        ssnc = &ssnczero;
                                }
                        }
-                       pos = i * 5;
+                       pos = i * SOFT_ARRAY_SZ;
 
                        /* Check for min/max values */
                        save_extrema(a->gtypes_nr, (void *) ssnc, (void *) ssnp,
@@ -5177,14 +5252,14 @@ __print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action
        }
 
        if (action & F_END) {
-               for (i = 0; (i < svg_p->nr_max) && (i < a->bitmap->b_size + 1); i++) {
+               for (i = 0; (i < a->item_list_sz) && (i < a->bitmap->b_size + 1); i++) {
 
                        /* Should current CPU (including CPU "all") be displayed? */
                        if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
                                /* No */
                                continue;
 
-                       pos = i * 5;
+                       pos = i * SOFT_ARRAY_SZ;
 
                        if (!i) {
                                /* This is CPU "all" */
@@ -5197,8 +5272,413 @@ __print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action
                        draw_activity_graphs(a->g_nr, g_type,
                                             title, g_title, item_name, group,
                                             spmin + pos, spmax + pos, out + pos, outsize + pos,
-                                            svg_p, record_hdr, FALSE, a->id, i);
+                                            svg_p, record_hdr, FALSE, a, i);
+               }
+
+               /* Free remaining structures */
+               free_graphs(out, outsize, spmin, spmax);
+       }
+}
+
+/*
+ ***************************************************************************
+ * Display pressure-stall CPU statistics in SVG.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @action     Action expected from current function.
+ * @svg_p      SVG specific parameters: Current graph number (.@graph_no),
+ *             flag indicating that a restart record has been previously
+ *             found (.@restart) and time used for the X axis origin
+ *             (@ust_time_ref).
+ * @itv                Interval of time in 1/100th of a second (only with F_MAIN action).
+ * @record_hdr Pointer on record header of current stats sample.
+ ***************************************************************************
+ */
+__print_funct_t svg_print_psicpu_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
+                                      unsigned long long itv, struct record_header *record_hdr)
+{
+       struct stats_psi_cpu
+               *psic = (struct stats_psi_cpu *) a->buf[curr],
+               *psip = (struct stats_psi_cpu *) a->buf[!curr];
+       int group[] = {3, 1};
+       int g_type[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH};
+       char *title[] = {"CPU pressure trends (some tasks)", "CPU stall time (some tasks)"};
+       char *g_title[] = {"%scpu-10", "%scpu-60", "%scpu-300",
+                          "%scpu"};
+       static double *spmin, *spmax;
+       static char **out;
+       static int *outsize;
+       double tval;
+
+       if (action & F_BEGIN) {
+               /*
+                * Allocate arrays that will contain the graphs data
+                * and the min/max values.
+                */
+               out = allocate_graph_lines(4, &outsize, &spmin, &spmax);
+       }
+
+       if (action & F_MAIN) {
+               /* Check for min/max values */
+               if (psic->some_acpu_10 > *spmax) {
+                       *spmax = psic->some_acpu_10;
+               }
+               if (psic->some_acpu_10 < *spmin) {
+                       *spmin = psic->some_acpu_10;
+               }
+               if (psic->some_acpu_60 > *(spmax + 1)) {
+                       *(spmax + 1) = psic->some_acpu_60;
+               }
+               if (psic->some_acpu_60 < *(spmin + 1)) {
+                       *(spmin + 1) = psic->some_acpu_60;
+               }
+               if (psic->some_acpu_300 > *(spmax + 2)) {
+                       *(spmax + 2) = psic->some_acpu_300;
+               }
+               if (psic->some_acpu_300 < *(spmin + 2)) {
+                       *(spmin + 2) = psic->some_acpu_300;
+               }
+               tval = ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv);
+               if (tval > *(spmax + 3)) {
+                       *(spmax + 3) = tval;
+               }
+               if (tval < *(spmin + 3)) {
+                       *(spmin + 3) = tval;
+               }
+
+               /* %scpu-10 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_acpu_10 / 100,
+                        out, outsize, svg_p->restart);
+               /* %scpu-60 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_acpu_60 / 100,
+                        out + 1, outsize + 1, svg_p->restart);
+               /* %scpu-300 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_acpu_300 / 100,
+                        out + 2, outsize + 2, svg_p->restart);
+               /* %scpu */
+               brappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        0.0,
+                        ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv),
+                        out + 3, outsize + 3, svg_p->dt);
+       }
+
+       if (action & F_END) {
+               /* Fix min/max values for pressure ratios */
+               *spmin /= 100; *spmax /= 100;
+               *(spmin + 1) /= 100; *(spmax + 1) /= 100;
+               *(spmin + 2) /= 100; *(spmax + 2) /= 100;
+
+               draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
+
+               /* Free remaining structures */
+               free_graphs(out, outsize, spmin, spmax);
+       }
+}
+
+/*
+ ***************************************************************************
+ * Display pressure-stall I/O statistics in SVG.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @action     Action expected from current function.
+ * @svg_p      SVG specific parameters: Current graph number (.@graph_no),
+ *             flag indicating that a restart record has been previously
+ *             found (.@restart) and time used for the X axis origin
+ *             (@ust_time_ref).
+ * @itv                Interval of time in 1/100th of a second (only with F_MAIN action).
+ * @record_hdr Pointer on record header of current stats sample.
+ ***************************************************************************
+ */
+__print_funct_t svg_print_psiio_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
+                                     unsigned long long itv, struct record_header *record_hdr)
+{
+       struct stats_psi_io
+               *psic = (struct stats_psi_io *) a->buf[curr],
+               *psip = (struct stats_psi_io *) a->buf[!curr];
+       int group[] = {3, 1, 3, 1};
+       int g_type[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH, SVG_LINE_GRAPH, SVG_BAR_GRAPH};
+       char *title[] = {"I/O pressure trends (some tasks)", "I/O stall time (some tasks)",
+                        "I/O pressure trends (full)", "I/O stall time (full)"};
+       char *g_title[] = {"%sio-10", "%sio-60", "%sio-300",
+                          "%sio",
+                          "%fio-10", "%fio-60", "%fio-300",
+                          "%fio"};
+       static double *spmin, *spmax;
+       static char **out;
+       static int *outsize;
+       double tval;
+
+       if (action & F_BEGIN) {
+               /*
+                * Allocate arrays that will contain the graphs data
+                * and the min/max values.
+                */
+               out = allocate_graph_lines(8, &outsize, &spmin, &spmax);
+       }
+
+       if (action & F_MAIN) {
+               /* Check for min/max values */
+               if (psic->some_aio_10 > *spmax) {
+                       *spmax = psic->some_aio_10;
+               }
+               if (psic->some_aio_10 < *spmin) {
+                       *spmin = psic->some_aio_10;
+               }
+               if (psic->some_aio_60 > *(spmax + 1)) {
+                       *(spmax + 1) = psic->some_aio_60;
+               }
+               if (psic->some_aio_60 < *(spmin + 1)) {
+                       *(spmin + 1) = psic->some_aio_60;
+               }
+               if (psic->some_aio_300 > *(spmax + 2)) {
+                       *(spmax + 2) = psic->some_aio_300;
+               }
+               if (psic->some_aio_300 < *(spmin + 2)) {
+                       *(spmin + 2) = psic->some_aio_300;
+               }
+               tval = ((double) psic->some_io_total - psip->some_io_total) / (100 * itv);
+               if (tval > *(spmax + 3)) {
+                       *(spmax + 3) = tval;
+               }
+               if (tval < *(spmin + 3)) {
+                       *(spmin + 3) = tval;
+               }
+
+               if (psic->full_aio_10 > *(spmax + 4)) {
+                       *(spmax + 4) = psic->full_aio_10;
+               }
+               if (psic->full_aio_10 < *(spmin + 4)) {
+                       *(spmin + 4) = psic->full_aio_10;
+               }
+               if (psic->full_aio_60 > *(spmax + 5)) {
+                       *(spmax + 5) = psic->full_aio_60;
+               }
+               if (psic->full_aio_60 < *(spmin + 5)) {
+                       *(spmin + 5) = psic->full_aio_60;
+               }
+               if (psic->full_aio_300 > *(spmax + 6)) {
+                       *(spmax + 6) = psic->full_aio_300;
+               }
+               if (psic->full_aio_300 < *(spmin + 6)) {
+                       *(spmin + 6) = psic->full_aio_300;
+               }
+               tval = ((double) psic->full_io_total - psip->full_io_total) / (100 * itv);
+               if (tval > *(spmax + 7)) {
+                       *(spmax + 7) = tval;
+               }
+               if (tval < *(spmin + 7)) {
+                       *(spmin + 7) = tval;
+               }
+
+               /* %sio-10 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_aio_10 / 100,
+                        out, outsize, svg_p->restart);
+               /* %sio-60 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_aio_60 / 100,
+                        out + 1, outsize + 1, svg_p->restart);
+               /* %sio-300 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_aio_300 / 100,
+                        out + 2, outsize + 2, svg_p->restart);
+               /* %sio */
+               brappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        0.0,
+                        ((double) psic->some_io_total - psip->some_io_total) / (100 * itv),
+                        out + 3, outsize + 3, svg_p->dt);
+
+               /* %fio-10 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->full_aio_10 / 100,
+                        out + 4, outsize + 4, svg_p->restart);
+               /* %fio-60 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->full_aio_60 / 100,
+                        out + 5, outsize + 5, svg_p->restart);
+               /* %fio-300 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->full_aio_300 / 100,
+                        out + 6, outsize + 6, svg_p->restart);
+               /* %fio */
+               brappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        0.0,
+                        ((double) psic->full_io_total - psip->full_io_total) / (100 * itv),
+                        out + 7, outsize + 7, svg_p->dt);
+       }
+
+       if (action & F_END) {
+               /* Fix min/max values for pressure ratios */
+               *spmin /= 100; *spmax /= 100;
+               *(spmin + 1) /= 100; *(spmax + 1) /= 100;
+               *(spmin + 2) /= 100; *(spmax + 2) /= 100;
+
+               *(spmin + 4) /= 100; *(spmax + 4) /= 100;
+               *(spmin + 5) /= 100; *(spmax + 5) /= 100;
+               *(spmin + 6) /= 100; *(spmax + 6) /= 100;
+
+               draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
+
+               /* Free remaining structures */
+               free_graphs(out, outsize, spmin, spmax);
+       }
+}
+
+/*
+ ***************************************************************************
+ * Display pressure-stall memory statistics in SVG.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @action     Action expected from current function.
+ * @svg_p      SVG specific parameters: Current graph number (.@graph_no),
+ *             flag indicating that a restart record has been previously
+ *             found (.@restart) and time used for the X axis origin
+ *             (@ust_time_ref).
+ * @itv                Interval of time in 1/100th of a second (only with F_MAIN action).
+ * @record_hdr Pointer on record header of current stats sample.
+ ***************************************************************************
+ */
+__print_funct_t svg_print_psimem_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
+                                      unsigned long long itv, struct record_header *record_hdr)
+{
+       struct stats_psi_mem
+               *psic = (struct stats_psi_mem *) a->buf[curr],
+               *psip = (struct stats_psi_mem *) a->buf[!curr];
+       int group[] = {3, 1, 3, 1};
+       int g_type[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH, SVG_LINE_GRAPH, SVG_BAR_GRAPH};
+       char *title[] = {"Memory pressure trends (some tasks)", "Memory stall time (some tasks)",
+                        "Memory pressure trends (full)", "Memory stall time (full)"};
+       char *g_title[] = {"%smem-10", "%smem-60", "%smem-300",
+                          "%smem",
+                          "%fmem-10", "%fmem-60", "%fmem-300",
+                          "%fmem"};
+       static double *spmin, *spmax;
+       static char **out;
+       static int *outsize;
+       double tval;
+
+       if (action & F_BEGIN) {
+               /*
+                * Allocate arrays that will contain the graphs data
+                * and the min/max values.
+                */
+               out = allocate_graph_lines(8, &outsize, &spmin, &spmax);
+       }
+
+       if (action & F_MAIN) {
+               /* Check for min/max values */
+               if (psic->some_amem_10 > *spmax) {
+                       *spmax = psic->some_amem_10;
+               }
+               if (psic->some_amem_10 < *spmin) {
+                       *spmin = psic->some_amem_10;
+               }
+               if (psic->some_amem_60 > *(spmax + 1)) {
+                       *(spmax + 1) = psic->some_amem_60;
+               }
+               if (psic->some_amem_60 < *(spmin + 1)) {
+                       *(spmin + 1) = psic->some_amem_60;
+               }
+               if (psic->some_amem_300 > *(spmax + 2)) {
+                       *(spmax + 2) = psic->some_amem_300;
+               }
+               if (psic->some_amem_300 < *(spmin + 2)) {
+                       *(spmin + 2) = psic->some_amem_300;
+               }
+               tval = ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv);
+               if (tval > *(spmax + 3)) {
+                       *(spmax + 3) = tval;
+               }
+               if (tval < *(spmin + 3)) {
+                       *(spmin + 3) = tval;
+               }
+
+               if (psic->full_amem_10 > *(spmax + 4)) {
+                       *(spmax + 4) = psic->full_amem_10;
+               }
+               if (psic->full_amem_10 < *(spmin + 4)) {
+                       *(spmin + 4) = psic->full_amem_10;
+               }
+               if (psic->full_amem_60 > *(spmax + 5)) {
+                       *(spmax + 5) = psic->full_amem_60;
+               }
+               if (psic->full_amem_60 < *(spmin + 5)) {
+                       *(spmin + 5) = psic->full_amem_60;
+               }
+               if (psic->full_amem_300 > *(spmax + 6)) {
+                       *(spmax + 6) = psic->full_amem_300;
+               }
+               if (psic->full_amem_300 < *(spmin + 6)) {
+                       *(spmin + 6) = psic->full_amem_300;
                }
+               tval = ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv);
+               if (tval > *(spmax + 7)) {
+                       *(spmax + 7) = tval;
+               }
+               if (tval < *(spmin + 7)) {
+                       *(spmin + 7) = tval;
+               }
+
+               /* %smem-10 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_amem_10 / 100,
+                        out, outsize, svg_p->restart);
+               /* %smem-60 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_amem_60 / 100,
+                        out + 1, outsize + 1, svg_p->restart);
+               /* %smem-300 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->some_amem_300 / 100,
+                        out + 2, outsize + 2, svg_p->restart);
+               /* %smem */
+               brappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        0.0,
+                        ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv),
+                        out + 3, outsize + 3, svg_p->dt);
+
+               /* %fmem-10 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->full_amem_10 / 100,
+                        out + 4, outsize + 4, svg_p->restart);
+               /* %fmem-60 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->full_amem_60 / 100,
+                        out + 5, outsize + 5, svg_p->restart);
+               /* %fmem-300 */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        (double) psic->full_amem_300 / 100,
+                        out + 6, outsize + 6, svg_p->restart);
+               /* %fmem */
+               brappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        0.0,
+                        ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv),
+                        out + 7, outsize + 7, svg_p->dt);
+       }
+
+       if (action & F_END) {
+               /* Fix min/max values for pressure ratios */
+               *spmin /= 100; *spmax /= 100;
+               *(spmin + 1) /= 100; *(spmax + 1) /= 100;
+               *(spmin + 2) /= 100; *(spmax + 2) /= 100;
+
+               *(spmin + 4) /= 100; *(spmax + 4) /= 100;
+               *(spmin + 5) /= 100; *(spmax + 5) /= 100;
+               *(spmin + 6) /= 100; *(spmax + 6) /= 100;
+
+               draw_activity_graphs(a->g_nr, g_type, title, g_title, NULL, group,
+                                    spmin, spmax, out, outsize, svg_p, record_hdr, FALSE, a, 0);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);