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

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