From 17809273cecd83c068931e5d7e73d126d98e6ac1 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Tue, 9 May 2017 14:34:13 +0100
Subject: [PATCH 1/2] [pacemaker] Collect /etc/default/pacemaker for
Debian/Ubuntu
Make /etc/default/pacemaker the default location for the Pacemaker
defaults file, and have the RedHatPlugin override this to the
/etc/sysconfig/pacemaker location as required.
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
sos/plugins/pacemaker.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/sos/plugins/pacemaker.py b/sos/plugins/pacemaker.py
index 0dac1da..74de433 100644
--- a/sos/plugins/pacemaker.py
+++ b/sos/plugins/pacemaker.py
@@ -17,12 +17,13 @@ from datetime import datetime, timedelta
import re
-class Pacemaker(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
+class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
"""HA Cluster resource manager"""
plugin_name = "pacemaker"
profiles = ("cluster", )
packages = ["pacemaker"]
+ defaults = "/etc/default/pacemaker"
option_list = [
("crm_from", "specify the start time for crm_report", "fast", False),
@@ -32,7 +33,7 @@ class Pacemaker(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
def setup(self):
self.add_copy_spec([
"/var/lib/pacemaker/cib/cib.xml",
- "/etc/sysconfig/pacemaker",
+ self.defaults,
"/var/log/pacemaker.log",
"/var/log/pcsd/pcsd.log"
])
@@ -76,4 +77,13 @@ class Pacemaker(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
r"\1********"
)
+
+class RedHatPacemaker(Pacemaker, RedHatPlugin):
+ """ Handle alternate location of pacemaker defaults file.
+ """
+ def setup(self):
+ self.defaults = "/etc/sysconfig/pacemaker"
+ super(RedHatPacemaker, self).setup()
+
+
# vim: et ts=4 sw=4
--
2.7.4
From 15b01889292ee3fca68ea76523be93af3be138f6 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Wed, 3 May 2017 09:48:29 +0200
Subject: [PATCH 2/2] [pacemaker] Collect user-defined logfile
/etc/sysconfig/pacemaker or /etc/default/pacemaker can specify pacemaker's
logfile that sos should collect.
Resolves: #1002.
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
sos/plugins/pacemaker.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/sos/plugins/pacemaker.py b/sos/plugins/pacemaker.py
index 74de433..9393831 100644
--- a/sos/plugins/pacemaker.py
+++ b/sos/plugins/pacemaker.py
@@ -15,6 +15,7 @@
from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from datetime import datetime, timedelta
import re
+import os.path
class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
@@ -45,6 +46,7 @@ class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
"pcs status",
"pcs property list --all"
])
+
# 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() -
@@ -70,6 +72,21 @@ class Pacemaker(Plugin, DebianPlugin, UbuntuPlugin):
(crm_scrub, crm_dest, crm_from),
chroot=self.tmp_in_sysroot())
+ # collect user-defined logfiles, matching pattern:
+ # PCMK_loggfile=filename
+ # specified in the pacemaker defaults file.
+ pattern = '^\s*PCMK_logfile=[\'\"]?(\S+)[\'\"]?\s*(\s#.*)?$'
+ if os.path.isfile(self.defaults):
+ with open(self.defaults) as f:
+ for line in f:
+ if re.match(pattern, line):
+ # remove trailing and leading quote marks, in case the
+ # line is e.g. PCMK_logfile="/var/log/pacemaker.log"
+ logfile = re.search(pattern, line).group(1)
+ for regexp in [r'^"', r'"$', r'^\'', r'\'$']:
+ logfile = re.sub(regexp, '', logfile)
+ self.add_copy_spec(logfile)
+
def postproc(self):
self.do_cmd_output_sub(
"pcs config",
--
2.7.4