]> granicus.if.org Git - sysstat/blobdiff - xml_stats.c
Merge branch 'scop-grep-E'
[sysstat] / xml_stats.c
index 1d21d0669979eb98ced4217856745d65f4a8ec8e..8d16ed7f94cd287e7ba7c1c32ea1a2ea3d8f44d6 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * xml_stats.c: Funtions used by sadf to display statistics in XML.
- * (C) 1999-2019 by Sebastien GODARD (sysstat <at> orange.fr)
+ * xml_stats.c: Functions used by sadf to display statistics in XML.
+ * (C) 1999-2021 by Sebastien GODARD (sysstat <at> orange.fr)
  *
  ***************************************************************************
  * This program is free software; you can redistribute it and/or modify it *
@@ -35,7 +35,7 @@
 #define _(string) (string)
 #endif
 
-extern unsigned int flags;
+extern uint64_t flags;
 
 /*
  ***************************************************************************
@@ -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.
@@ -462,7 +489,7 @@ __print_funct_t xml_print_memory_stats(struct activity *a, int curr, int tab,
                *smc = (struct stats_memory *) a->buf[curr];
        unsigned long long nousedmem;
 
-       xprintf(tab, "<memory per=\"second\" unit=\"kB\">");
+       xprintf(tab, "<memory unit=\"kB\">");
 
        if (DISPLAY_MEMORY(a->opt_flags)) {
 
@@ -718,8 +745,9 @@ __print_funct_t xml_print_disk_stats(struct activity *a, int curr, int tab,
                }
 
                /* Get device name */
-               dev_name = get_sa_devname(sdc->major, sdc->minor,
-                                         sdc->wwn, sdc->part_nr, flags);
+               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 (a->item_list != NULL) {
                        /* A list of devices has been entered on the command line */
@@ -784,7 +812,7 @@ __print_funct_t xml_print_net_dev_stats(struct activity *a, int curr, int tab,
        struct stats_net_dev *sndc, *sndp, sndzero;
        double rxkb, txkb, ifutil;
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        memset(&sndzero, 0, STATS_NET_DEV_SIZE);
@@ -860,7 +888,7 @@ __print_funct_t xml_print_net_edev_stats(struct activity *a, int curr, int tab,
        int i, j;
        struct stats_net_edev *snedc, *snedp, snedzero;
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
@@ -935,7 +963,7 @@ __print_funct_t xml_print_net_nfs_stats(struct activity *a, int curr, int tab,
                *snnc = (struct stats_net_nfs *) a->buf[curr],
                *snnp = (struct stats_net_nfs *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -980,7 +1008,7 @@ __print_funct_t xml_print_net_nfsd_stats(struct activity *a, int curr, int tab,
                *snndc = (struct stats_net_nfsd *) a->buf[curr],
                *snndp = (struct stats_net_nfsd *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1034,7 +1062,7 @@ __print_funct_t xml_print_net_sock_stats(struct activity *a, int curr, int tab,
        struct stats_net_sock
                *snsc = (struct stats_net_sock *) a->buf[curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1079,7 +1107,7 @@ __print_funct_t xml_print_net_ip_stats(struct activity *a, int curr, int tab,
                *snic = (struct stats_net_ip *) a->buf[curr],
                *snip = (struct stats_net_ip *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1128,7 +1156,7 @@ __print_funct_t xml_print_net_eip_stats(struct activity *a, int curr, int tab,
                *sneic = (struct stats_net_eip *) a->buf[curr],
                *sneip = (struct stats_net_eip *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1177,7 +1205,7 @@ __print_funct_t xml_print_net_icmp_stats(struct activity *a, int curr, int tab,
                *snic = (struct stats_net_icmp *) a->buf[curr],
                *snip = (struct stats_net_icmp *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1238,7 +1266,7 @@ __print_funct_t xml_print_net_eicmp_stats(struct activity *a, int curr, int tab,
                *sneic = (struct stats_net_eicmp *) a->buf[curr],
                *sneip = (struct stats_net_eicmp *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1295,7 +1323,7 @@ __print_funct_t xml_print_net_tcp_stats(struct activity *a, int curr, int tab,
                *sntc = (struct stats_net_tcp *) a->buf[curr],
                *sntp = (struct stats_net_tcp *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1336,7 +1364,7 @@ __print_funct_t xml_print_net_etcp_stats(struct activity *a, int curr, int tab,
                *snetc = (struct stats_net_etcp *) a->buf[curr],
                *snetp = (struct stats_net_etcp *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1379,7 +1407,7 @@ __print_funct_t xml_print_net_udp_stats(struct activity *a, int curr, int tab,
                *snuc = (struct stats_net_udp *) a->buf[curr],
                *snup = (struct stats_net_udp *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1419,7 +1447,7 @@ __print_funct_t xml_print_net_sock6_stats(struct activity *a, int curr, int tab,
        struct stats_net_sock6
                *snsc = (struct stats_net_sock6 *) a->buf[curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1460,7 +1488,7 @@ __print_funct_t xml_print_net_ip6_stats(struct activity *a, int curr, int tab,
                *snic = (struct stats_net_ip6 *) a->buf[curr],
                *snip = (struct stats_net_ip6 *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1513,7 +1541,7 @@ __print_funct_t xml_print_net_eip6_stats(struct activity *a, int curr, int tab,
                *sneic = (struct stats_net_eip6 *) a->buf[curr],
                *sneip = (struct stats_net_eip6 *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1568,7 +1596,7 @@ __print_funct_t xml_print_net_icmp6_stats(struct activity *a, int curr, int tab,
                *snic = (struct stats_net_icmp6 *) a->buf[curr],
                *snip = (struct stats_net_icmp6 *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1635,7 +1663,7 @@ __print_funct_t xml_print_net_eicmp6_stats(struct activity *a, int curr, int tab
                *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
                *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -1690,7 +1718,7 @@ __print_funct_t xml_print_net_udp6_stats(struct activity *a, int curr, int tab,
                *snuc = (struct stats_net_udp6 *) a->buf[curr],
                *snup = (struct stats_net_udp6 *) a->buf[!curr];
 
-       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+       if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
                goto close_xml_markup;
 
        xml_markup_network(tab, OPEN_XML_MARKUP);
@@ -2085,17 +2113,19 @@ __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab
 {
        int i;
        struct stats_filesystem *sfc;
+       char *dev_name;
 
        xprintf(tab++, "<filesystems>");
 
        for (i = 0; i < a->nr[curr]; i++) {
-
                sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
 
+               /* 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_list_item(a->item_list,
-                                             DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
+                       if (!search_list_item(a->item_list, dev_name))
                                /* Device not found */
                                continue;
                }
@@ -2109,7 +2139,7 @@ __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab
                        "Iused=\"%llu\" "
                        "Iused-percent=\"%.2f\"/>",
                        DISPLAY_MOUNT(a->opt_flags) ? "mountp" : "fsname",
-                       DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
+                       dev_name,
                        (double) sfc->f_bfree / 1024 / 1024,
                        (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
                        /* f_blocks is not zero. But test it anyway ;-) */
@@ -2276,3 +2306,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_avg=\"%.2f\"/>",
+               (double) psic->some_acpu_10  / 100,
+               (double) psic->some_acpu_60  / 100,
+               (double) psic->some_acpu_300 / 100,
+               ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * 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_avg=\"%.2f\" "
+               "full_avg10=\"%.2f\" "
+               "full_avg60=\"%.2f\" "
+               "full_avg300=\"%.2f\" "
+               "full_avg=\"%.2f\"/>",
+               (double) psic->some_aio_10  / 100,
+               (double) psic->some_aio_60  / 100,
+               (double) psic->some_aio_300 / 100,
+               ((double) psic->some_io_total - psip->some_io_total) / (100 * itv),
+               (double) psic->full_aio_10  / 100,
+               (double) psic->full_aio_60  / 100,
+               (double) psic->full_aio_300 / 100,
+               ((double) psic->full_io_total - psip->full_io_total) / (100 * 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_avg=\"%.2f\" "
+               "full_avg10=\"%.2f\" "
+               "full_avg60=\"%.2f\" "
+               "full_avg300=\"%.2f\" "
+               "full_avg=\"%.2f\"/>",
+               (double) psic->some_amem_10  / 100,
+               (double) psic->some_amem_60  / 100,
+               (double) psic->some_amem_300 / 100,
+               ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv),
+               (double) psic->full_amem_10  / 100,
+               (double) psic->full_amem_60  / 100,
+               (double) psic->full_amem_300 / 100,
+               ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv));
+       tab--;
+
+close_xml_markup:
+       if (CLOSE_MARKUP(a->options)) {
+               xml_markup_psi(tab, CLOSE_XML_MARKUP);
+       }
+}