diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2017-05-03 09:48:29 +0200 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2017-05-09 14:48:46 +0100 |
commit | 15b01889292ee3fca68ea76523be93af3be138f6 (patch) | |
tree | e2dcb5999b8cb7cd3734c199256048a85f182b80 | |
parent | 17809273cecd83c068931e5d7e73d126d98e6ac1 (diff) | |
download | sos-15b01889292ee3fca68ea76523be93af3be138f6.tar.gz |
[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>
-rw-r--r-- | sos/plugins/pacemaker.py | 17 |
1 files changed, 17 insertions, 0 deletions
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", |