aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2013-04-22 16:15:05 +0100
committerBryn M. Reeves <bmr@redhat.com>2013-04-22 16:15:05 +0100
commit44f0d96b5a06ab8f1811134572ce35e9f8790483 (patch)
tree8e0a8d80579e6996f0a0e6a6c1ec948128566f58
parent8856596a68fc75ce36cb46b084b05097a4d6f5ff (diff)
downloadsos-44f0d96b5a06ab8f1811134572ce35e9f8790483.tar.gz
Fix pre-checks in sar module and enable XML output collection
Move the check on the sar logging directory from setup() to a check_enabled() method and add XML data collection via sadf -x 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>
-rw-r--r--sos/plugins/sar.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/sos/plugins/sar.py b/sos/plugins/sar.py
index 2d977ae9..4e6cf51c 100644
--- a/sos/plugins/sar.py
+++ b/sos/plugins/sar.py
@@ -15,24 +15,42 @@
from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
import os
-class Sar(Plugin, RedHatPlugin):
+class Sar(Plugin,):
""" Collect system activity reporter data
"""
packages = ('sysstat',)
sa_path = '/var/log/sa'
+ def check_enabled(self):
+ # check to see if we are force-enabled with no sar installation
+ if not os.path.exists(self.sa_path) or not os.path.isdir(self.sa_path):
+ self.soslog.info("sar directory %s does not exist" % self.sa_path
+ + " or is not a directory")
+ return False
+ return True
+
def setup(self):
dirList = os.listdir(self.sa_path)
# find all the sa file that don't have an existing sar file
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_path = os.path.join(self.sa_path, fname)
- sar_command = 'sh -c "LANG=C sar -A -f %s"' % sar_path
- self.collectOutputNow(sar_command, sar_filename,
- root_symlink=sar_filename)
+ sar_cmd = 'sh -c "LANG=C sar -A -f %s"' % sa_data_path
+ self.add_cmd_output(sar_cmd, sar_filename)
+ sadf_cmd = "sadf -x %s" % sa_data_path
+ self.add_cmd_output(sadf_cmd, "%s.xml" % fname)
+ self.add_copy_spec(os.path.join(self.sa_path, "sar*"))
+
+
+class RedHatSar(Sar, RedHatPlugin):
+ """ Collect system activity reporter data
+ """
+
+ sa_path = '/var/log/sa'
+
class DebianSar(Sar, DebianPlugin, UbuntuPlugin):
""" Collect system activity reporter data