Blame SOURCES/0006-Filesystems-statistics-part-6-XML-output-format.patch

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