From b3a0f481304e76b5fe3ec69025df20cea16e6f0e Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 18 May 2013 22:04:27 +0200 Subject: [PATCH] Filesystems statistics (part 6): XML output format This patch adds XML output format for filesystems statistics. This format can be displayed with sadf option -x. DTD and XML Schema (xsd) documents have also been updated. (cherry picked from commit 1eddc64a1db0efd5cdffd5d272adb9f8d4ccb589) --- sadf.h | 2 +- xml/{sysstat-2.15.dtd => sysstat-2.16.dtd} | 18 ++++++++++++-- xml/sysstat.xsd | 22 ++++++++++++++++- xml_stats.c | 38 +++++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 5 deletions(-) rename xml/{sysstat-2.15.dtd => sysstat-2.16.dtd} (96%) diff --git a/sadf.h b/sadf.h index 786d3b0..198568a 100644 --- a/sadf.h +++ b/sadf.h @@ -9,7 +9,7 @@ #include "sa.h" /* DTD version for XML output */ -#define XML_DTD_VERSION "2.15" +#define XML_DTD_VERSION "2.16" /* Possible actions for functions used to display reports */ #define F_BEGIN 0x01 diff --git a/xml/sysstat-2.15.dtd b/xml/sysstat-2.16.dtd similarity index 96% rename from xml/sysstat-2.15.dtd rename to xml/sysstat-2.16.dtd index e0b7bfb..06faed2 100644 --- a/xml/sysstat-2.15.dtd +++ b/xml/sysstat-2.16.dtd @@ -1,11 +1,11 @@ - + - + @@ -551,3 +551,17 @@ manufact CDATA #REQUIRED product CDATA #REQUIRED > + + + + + diff --git a/xml/sysstat.xsd b/xml/sysstat.xsd index 8304ac5..09818f6 100644 --- a/xml/sysstat.xsd +++ b/xml/sysstat.xsd @@ -1,7 +1,7 @@ - -- XML Schema v2.15 for sysstat. See sadf.h -- + -- XML Schema v2.16 for sysstat. See sadf.h -- @@ -97,6 +97,7 @@ + @@ -723,4 +724,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/xml_stats.c b/xml_stats.c index 0a15f98..f41d520 100644 --- a/xml_stats.c +++ b/xml_stats.c @@ -2005,5 +2005,41 @@ close_xml_markup: __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab, unsigned long long itv) { - /* FIXME */ + int i; + struct stats_filesystem *sfc; + + xprintf(tab, ""); + tab++; + + for (i = 0; i < a->nr; i++) { + + sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize); + + if (!sfc->f_blocks) + /* Size of filesystem is null: We are at the end of the list */ + break; + + xprintf(tab, "", + sfc->fs_name, + (double) sfc->f_bfree / 1024 / 1024, + (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024, + /* f_blocks is not null. But test it anyway ;-) */ + sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks) + : 0.0, + sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks) + : 0.0, + sfc->f_ffree, + sfc->f_files - sfc->f_ffree, + sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files) + : 0.0); + } + + xprintf(--tab, ""); } -- 2.14.3