]> granicus.if.org Git - sysstat/commitdiff
sadf: XML: Add PSI support
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 12 Apr 2020 12:16:29 +0000 (14:16 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 12 Apr 2020 14:08:41 +0000 (16:08 +0200)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
activity.c
xml_stats.c
xml_stats.h

index d4e70971f80f20452ae106536ff3a8a3a24c3280..74c9e0a3fc25f6526818a12f3ffa077702ba8520 100644 (file)
@@ -1895,7 +1895,7 @@ struct activity psi_cpu_act = {
        .ftypes_nr      = {0, 0, 0},
 #ifdef SOURCE_SADF
        .f_render       = render_psicpu_stats,
-//FIXME        .f_xml_print    = xml_print_psicpu_stats,
+       .f_xml_print    = xml_print_psicpu_stats,
 //FIXME        .f_json_print   = json_print_psicpu_stats,
 //FIXME        .f_svg_print    = svg_print_psicpu_stats,
        .f_raw_print    = raw_print_psicpu_stats,
@@ -1941,7 +1941,7 @@ struct activity psi_io_act = {
        .ftypes_nr      = {0, 0, 0},
 #ifdef SOURCE_SADF
        .f_render       = render_psiio_stats,
-//FIXME        .f_xml_print    = xml_print_psiio_stats,
+       .f_xml_print    = xml_print_psiio_stats,
 //FIXME        .f_json_print   = json_print_psiio_stats,
 //FIXME        .f_svg_print    = svg_print_psiio_stats,
        .f_raw_print    = raw_print_psiio_stats,
@@ -1968,7 +1968,7 @@ struct activity psi_io_act = {
 /* Pressure-stall memory activity */
 struct activity psi_mem_act = {
        .id             = A_PSI_MEM,
-       .options        = AO_COLLECTED,
+       .options        = AO_COLLECTED + AO_CLOSE_MARKUP,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_DEFAULT,
 #ifdef SOURCE_SADC
@@ -1987,7 +1987,7 @@ struct activity psi_mem_act = {
        .ftypes_nr      = {0, 0, 0},
 #ifdef SOURCE_SADF
        .f_render       = render_psimem_stats,
-//FIXME        .f_xml_print    = xml_print_psimem_stats,
+       .f_xml_print    = xml_print_psimem_stats,
 //FIXME        .f_json_print   = json_print_psimem_stats,
 //FIXME        .f_svg_print    = svg_print_psimem_stats,
        .f_raw_print    = raw_print_psimem_stats,
@@ -2075,10 +2075,12 @@ struct activity *act[NR_ACT] = {
        &pwr_temp_act,
        &pwr_in_act,
        &pwr_wghfreq_act,
-       &pwr_usb_act,           /* AO_CLOSE_MARKUP */
+       &pwr_usb_act,   /* AO_CLOSE_MARKUP */
        /* </power-management> */
        &filesystem_act,
+       /* <psi> */
        &psi_cpu_act,
        &psi_io_act,
-       &psi_mem_act
+       &psi_mem_act    /* AO_CLOSE_MARKUP */
+       /* </psi> */
 };
index 1d21d0669979eb98ced4217856745d65f4a8ec8e..27aa31ef424903bb203a69c807c94fde64d6cb58 100644 (file)
@@ -91,6 +91,33 @@ void xml_markup_power_management(int tab, int action)
        }
 }
 
+/*
+ ***************************************************************************
+ * Open or close <psi> markup.
+ *
+ * IN:
+ * @tab                Number of tabulations.
+ * @action     Open or close action.
+ ***************************************************************************
+ */
+void xml_markup_psi(int tab, int action)
+{
+       static int markup_state = CLOSE_XML_MARKUP;
+
+       if (action == markup_state)
+               return;
+       markup_state = action;
+
+       if (action == OPEN_XML_MARKUP) {
+               /* Open markup */
+               xprintf(tab, "<psi per=\"second\">");
+       }
+       else {
+               /* Close markup */
+               xprintf(tab, "</psi>");
+       }
+}
+
 /*
  ***************************************************************************
  * Display CPU statistics in XML.
@@ -2276,3 +2303,142 @@ close_xml_markup:
                xml_markup_network(tab, CLOSE_XML_MARKUP);
        }
 }
+
+/*
+ ***************************************************************************
+ * Display pressure-stall CPU statistics in XML.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @tab                Indentation in XML output.
+ * @itv                Interval of time in 1/100th of a second.
+ ***************************************************************************
+ */
+__print_funct_t xml_print_psicpu_stats(struct activity *a, int curr, int tab,
+                                      unsigned long long itv)
+{
+       struct stats_psi_cpu
+               *psic = (struct stats_psi_cpu *) a->buf[curr],
+               *psip = (struct stats_psi_cpu *) a->buf[!curr];
+
+       if (!IS_SELECTED(a->options))
+               goto close_xml_markup;
+
+       xml_markup_psi(tab, OPEN_XML_MARKUP);
+       tab++;
+
+       xprintf(tab, "<psi-cpu "
+               "some_avg10=\"%.2f\" "
+               "some_avg60=\"%.2f\" "
+               "some_avg300=\"%.2f\" "
+               "some_total=\"%.2f\"/>",
+               (double) psic->some_acpu_10  / 100,
+               (double) psic->some_acpu_60  / 100,
+               (double) psic->some_acpu_300 / 100,
+               S_VALUE(psip->some_cpu_total, psic->some_cpu_total, itv));
+       tab--;
+
+close_xml_markup:
+       if (CLOSE_MARKUP(a->options)) {
+               xml_markup_psi(tab, CLOSE_XML_MARKUP);
+       }
+}
+
+/*
+ ***************************************************************************
+ * Display pressure-stall I/O statistics in XML.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @tab                Indentation in XML output.
+ * @itv                Interval of time in 1/100th of a second.
+ ***************************************************************************
+ */
+__print_funct_t xml_print_psiio_stats(struct activity *a, int curr, int tab,
+                                     unsigned long long itv)
+{
+       struct stats_psi_io
+               *psic = (struct stats_psi_io *) a->buf[curr],
+               *psip = (struct stats_psi_io *) a->buf[!curr];
+
+       if (!IS_SELECTED(a->options))
+               goto close_xml_markup;
+
+       xml_markup_psi(tab, OPEN_XML_MARKUP);
+       tab++;
+
+       xprintf(tab, "<psi-io "
+               "some_avg10=\"%.2f\" "
+               "some_avg60=\"%.2f\" "
+               "some_avg300=\"%.2f\" "
+               "some_total=\"%.2f\" "
+               "full_avg10=\"%.2f\" "
+               "full_avg60=\"%.2f\" "
+               "full_avg300=\"%.2f\" "
+               "full_total=\"%.2f\"/>",
+               (double) psic->some_aio_10  / 100,
+               (double) psic->some_aio_60  / 100,
+               (double) psic->some_aio_300 / 100,
+               S_VALUE(psip->some_io_total, psic->some_io_total, itv),
+               (double) psic->full_aio_10  / 100,
+               (double) psic->full_aio_60  / 100,
+               (double) psic->full_aio_300 / 100,
+               S_VALUE(psip->full_io_total, psic->full_io_total, itv));
+       tab--;
+
+close_xml_markup:
+       if (CLOSE_MARKUP(a->options)) {
+               xml_markup_psi(tab, CLOSE_XML_MARKUP);
+       }
+}
+
+/*
+ ***************************************************************************
+ * Display pressure-stall memory statistics in XML.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @tab                Indentation in XML output.
+ * @itv                Interval of time in 1/100th of a second.
+ ***************************************************************************
+ */
+__print_funct_t xml_print_psimem_stats(struct activity *a, int curr, int tab,
+                                      unsigned long long itv)
+{
+       struct stats_psi_mem
+               *psic = (struct stats_psi_mem *) a->buf[curr],
+               *psip = (struct stats_psi_mem *) a->buf[!curr];
+
+       if (!IS_SELECTED(a->options))
+               goto close_xml_markup;
+
+       xml_markup_psi(tab, OPEN_XML_MARKUP);
+       tab++;
+
+       xprintf(tab, "<psi-mem "
+               "some_avg10=\"%.2f\" "
+               "some_avg60=\"%.2f\" "
+               "some_avg300=\"%.2f\" "
+               "some_total=\"%.2f\" "
+               "full_avg10=\"%.2f\" "
+               "full_avg60=\"%.2f\" "
+               "full_avg300=\"%.2f\" "
+               "full_total=\"%.2f\"/>",
+               (double) psic->some_amem_10  / 100,
+               (double) psic->some_amem_60  / 100,
+               (double) psic->some_amem_300 / 100,
+               S_VALUE(psip->some_mem_total, psic->some_mem_total, itv),
+               (double) psic->full_amem_10  / 100,
+               (double) psic->full_amem_60  / 100,
+               (double) psic->full_amem_300 / 100,
+               S_VALUE(psip->full_mem_total, psic->full_mem_total, itv));
+       tab--;
+
+close_xml_markup:
+       if (CLOSE_MARKUP(a->options)) {
+               xml_markup_psi(tab, CLOSE_XML_MARKUP);
+       }
+}
index d9b95493465d70cbe1734c641b2ff6483539c824..65457953d2c364c2e7a5f90a81a98cb187b3d400 100644 (file)
@@ -93,5 +93,11 @@ __print_funct_t xml_print_fchost_stats
        (struct activity *, int, int, unsigned long long);
 __print_funct_t xml_print_softnet_stats
        (struct activity *, int, int, unsigned long long);
+__print_funct_t xml_print_psicpu_stats
+       (struct activity *, int, int, unsigned long long);
+__print_funct_t xml_print_psiio_stats
+       (struct activity *, int, int, unsigned long long);
+__print_funct_t xml_print_psimem_stats
+       (struct activity *, int, int, unsigned long long);
 
 #endif /* _XML_STATS_H */