]> granicus.if.org Git - sysstat/commitdiff
SVG: Add SVG output for kernel tables statistics
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Apr 2016 13:02:28 +0000 (15:02 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 16 Apr 2016 13:02:28 +0000 (15:02 +0200)
These graphs correspond to the output of "sar -v".

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

index 90cba4a8f66fdc2c98cf55a73ee1319c24c329cf..ed36778a6fb0707c2560f89c3799f83707f2b4dc 100644 (file)
@@ -328,9 +328,10 @@ struct activity ktables_act = {
        .f_render       = render_ktables_stats,
        .f_xml_print    = xml_print_ktables_stats,
        .f_json_print   = json_print_ktables_stats,
+       .f_svg_print    = svg_print_ktables_stats,
        .hdr_line       = "dentunusd;file-nr;inode-nr;pty-nr",
        .name           = "A_KTABLES",
-       .g_nr           = 0,
+       .g_nr           = 2,
 #endif
        .nr             = 1,
        .nr2            = 1,
index b6110b9b3d8b2c8c8505a2e353a34da1816872ae..c2d6d701d44f2b4107aaae2422db2fa50e3cc468 100644 (file)
@@ -1556,6 +1556,74 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
        }
 }
 
+/*
+ ***************************************************************************
+ * Display queue and load 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 a pointer on a record header structure
+ *             (.@record_hdr) containing the first stats sample.
+ * @itv                Interval of time in jiffies (only with F_MAIN action).
+ * @record_hdr Pointer on record header of current stats sample.
+ ***************************************************************************
+ */
+__print_funct_t svg_print_ktables_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
+                                       unsigned long long itv, struct record_header *record_hdr)
+{
+       struct stats_ktables
+               *skc = (struct stats_ktables *) a->buf[curr];
+       int group[] = {3, 1};
+       char *title[] = {"Kernel tables (1)", "Kernel tables (2)"};
+       char *g_title[] = {"~file-nr", "~inode-nr", "~dentunusd",
+                          "~pty-nr"};
+       static double *spmin, *spmax;
+       static char **out;
+       static int *outsize;
+
+       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 */
+               save_extrema(0, 0, 4, (void *) a->buf[curr], NULL,
+                            itv, spmin, spmax);
+               /* file-nr */
+               lniappend(record_hdr->ust_time - svg_p->record_hdr->ust_time,
+                         (unsigned long) skc->file_used,
+                         out, outsize, svg_p->restart);
+               /* inode-nr */
+               lniappend(record_hdr->ust_time - svg_p->record_hdr->ust_time,
+                         (unsigned long) skc->inode_used,
+                         out + 1, outsize + 1, svg_p->restart);
+               /* dentunusd */
+               lniappend(record_hdr->ust_time - svg_p->record_hdr->ust_time,
+                         (unsigned long) skc->dentry_stat,
+                         out + 2, outsize + 2, svg_p->restart);
+               /* pty-nr */
+               lniappend(record_hdr->ust_time - svg_p->record_hdr->ust_time,
+                         (unsigned long) skc->pty_nr,
+                         out + 3, outsize + 3, svg_p->restart);
+       }
+
+       if (action & F_END) {
+               draw_activity_graphs(a->g_nr, SVG_LINE_GRAPH, title, g_title, NULL, group,
+                                    spmin, spmax, out, outsize, svg_p, record_hdr);
+
+               /* Free remaining structures */
+               free_graphs(out, outsize, spmin, spmax);
+       }
+}
+
 /*
  ***************************************************************************
  * Display queue and load statistics in SVG
index 63d640276627e3055054b87762da07158e097ea4..f2cbb300bfdaeb6be660524091a4b490cfc1c1dc 100644 (file)
@@ -32,6 +32,9 @@ __print_funct_t svg_print_io_stats
 __print_funct_t svg_print_memory_stats
        (struct activity *, int, int, struct svg_parm *, unsigned long long,
         struct record_header *);
+__print_funct_t svg_print_ktables_stats
+       (struct activity *, int, int, struct svg_parm *, unsigned long long,
+        struct record_header *);
 __print_funct_t svg_print_queue_stats
        (struct activity *, int, int, struct svg_parm *, unsigned long long,
         struct record_header *);