From 6be750e4be8903edbeee8820e6d2ed6cd10fcde9 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Mon, 22 Apr 2013 16:15:05 +0100
Subject: [PATCH] Enable XML sar data collection

Add XML data collection via sadf -x to the sar plug-in to allow
the collected performance data to be imported by other tools on
the analysis host.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>

Conflicts:
	sos/plugins/sar.py
---
 sos/plugins/sar.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sos/plugins/sar.py b/sos/plugins/sar.py
index d10fb2f..d54f33e 100644
--- a/sos/plugins/sar.py
+++ b/sos/plugins/sar.py
@@ -18,10 +18,12 @@ import os
 class sar(sos.plugintools.PluginBase):
     """Generate the sar file from /var/log/sa/saXX files
     """
+
+    sa_path = "/var/log/sa"
+
     def setup(self):
-        path="/var/log/sa"
         try:
-            dirList=os.listdir(path)
+            dirList=os.listdir(self.sa_path)
         except:
             self.soslog.error("sar: could not list /var/log/sa")
             return
@@ -29,9 +31,12 @@ class sar(sos.plugintools.PluginBase):
         for fname in dirList:
             if fname[0:2] == 'sa' and fname[2] != 'r':
                 sar_filename = 'sar' + fname[2:4]
+                sa_data_path = os.path.join(self.sa_path, fname)
                 if sar_filename not in dirList:
                     sar_command = "/usr/bin/sar -A -f /var/log/sa/" + fname
                     self.collectOutputNow(sar_command, sar_filename, symlink=sar_filename)
+                sadf_cmd = "/usr/bin/sadf -x %s" % sa_data_path
+                self.collectExtOutput(sadf_cmd, "%s.xml" % fname)
         return
 
     def checkenabled(self):
-- 
1.9.3

