/*
- * 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 *
#define _(string) (string)
#endif
-extern unsigned int flags;
+extern uint64_t flags;
/*
***************************************************************************
}
}
+/*
+ ***************************************************************************
+ * 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.
*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)) {
}
/* 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 */
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);
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);
*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);
*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);
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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
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);
*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);
*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);
*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);
*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);
*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);
{
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;
}
"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 ;-) */
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);
+ }
+}