]> granicus.if.org Git - sysstat/commitdiff
sadf: SVG: Make sure gXX-0 id exists for memory activity
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 9 Jul 2018 13:27:26 +0000 (15:27 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 9 Jul 2018 13:27:26 +0000 (15:27 +0200)
A_MEMORY activity (which has two possible outputs: memory statistics and
swap statistics) might have no "gXX-0" id in SVG file if memory
statistics hadn't been selected. This would break corresponding link in
the table of contents displayed by sadf with its option "showtoc", e.g.:

sadf -g -O showtoc -- -S > output.svg

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

index bca06073c3a6adb1ea09b0e160ce41c16c205b53..3905f173b5993a9171d2951cbf861e25a0bae05b 100644 (file)
@@ -1687,6 +1687,7 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
+       static int xid = 0;
        double tval;
        int i;
        unsigned long long nousedmem;
@@ -1862,15 +1863,18 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                }
 
                if (DISPLAY_MEMORY(a->opt_flags)) {
-                       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, 0);
+                       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)) {
+                               xid++;
+                       }
                }
 
                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, 1);
+                                            svg_p, record_hdr, FALSE, a->id, xid);
                }
 
                /* Free remaining structures */