From 15b01889292ee3fca68ea76523be93af3be138f6 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Wed, 3 May 2017 09:48:29 +0200 Subject: [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 Signed-off-by: Bryn M. Reeves --- sos/plugins/pacemaker.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sos/plugins/pacemaker.py b/sos/plugins/pacemaker.py index 74de4336..93938316 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", -- cgit