From 4ab4b086c1011997246c40d4c97079c3c001031c Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Fri, 31 Jan 2014 15:08:28 +0000 Subject: [PATCH 01/72] Fix cluster module crm_report support The cluster plugin used an obsolete sos-2.2 method to determine the command output directory. This causes an excaption at runtime since the referenced properties no longer exist. The crm_report script also expects a --from date and will not collect data unless this is passed. Default to passing a value 72 hours before the current time and add a 'crm_from' option to the cluster module to allow the user to override this. Signed-off-by: Bryn M. Reeves --- sos/plugins/cluster.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/sos/plugins/cluster.py b/sos/plugins/cluster.py index 50e0e0b..c2ce42b 100644 --- a/sos/plugins/cluster.py +++ b/sos/plugins/cluster.py @@ -13,16 +13,17 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, RedHatPlugin -import re +import re, os from glob import glob +from datetime import datetime, timedelta class Cluster(Plugin, RedHatPlugin): """cluster suite and GFS related information """ plugin_name = 'cluster' - option_list = [("gfslockdump", - 'gather output of gfs lockdumps', 'slow', False), + option_list = [("gfslockdump", 'gather output of gfs lockdumps', 'slow', False), + ("crm_from", 'specify the --from parameter passed to crm_report', 'fast', False), ('lockdump', 'gather dlm lockdumps', 'slow', False)] packages = [ @@ -83,9 +84,21 @@ class Cluster(Plugin, RedHatPlugin): self.add_cmd_output("dlm_tool dump") self.add_cmd_output("dlm_tool ls -n") self.add_cmd_output("mkqdisk -L") - crm_dest = os.path.join(self.cInfo['cmddir'], - self.name(), 'crm_report') - self.collectExtOutput("crm_report -S --dest %s" % crm_dest) + # crm_report needs to be given a --from "YYYY-MM-DD HH:MM:SS" start + # time in order to collect data. + crm_from = (datetime.today() + - timedelta(hours=72)).strftime("%Y-%m-%d %H:%m:%S") + if self.get_option('crm_from') != False: + if re.match(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}', + str(self.getOption('crm_from'))): + crm_from = self.getOption('crm_from') + else: + self.soslog.error("crm_from parameter '%s' is not a valid date" + % self.getOption('crm_from')) + + crm_dest = os.path.join(self.get_cmd_dir(), 'crm_report') + self.add_cmd_output('crm_report -S -d --dest %s --from "%s"' + % (crm_dest, crm_from)) def do_lockdump(self): status, output, time = self.call_ext_prog("dlm_tool ls") @@ -106,8 +119,6 @@ class Cluster(Plugin, RedHatPlugin): self.do_file_sub(cluster_conf, r"(\s*\