diff options
-rw-r--r-- | sos/plugins/corosync.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sos/plugins/corosync.py b/sos/plugins/corosync.py index ee8504ce..90f73e85 100644 --- a/sos/plugins/corosync.py +++ b/sos/plugins/corosync.py @@ -13,6 +13,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +import os.path import re @@ -41,16 +42,23 @@ class Corosync(Plugin): ]) self.call_ext_prog("killall -USR2 corosync") + corosync_conf = "/etc/corosync/corosync.conf" + if not os.path.exists(corosync_conf): + return + # collect user-defined logfiles, matching either of pattern: # log_size: filename # or # logging.log_size: filename # (it isnt precise but sufficient) pattern = '^\s*(logging.)?logfile:\s*(\S+)$' - with open("/etc/corosync/corosync.conf") as f: - for line in f: - if re.match(pattern, line): - self.add_copy_spec(re.search(pattern, line).group(2)) + try: + with open("/etc/corosync/corosync.conf") as f: + for line in f: + if re.match(pattern, line): + self.add_copy_spec(re.search(pattern, line).group(2)) + except IOError as e: + self._log_warn("could not read from %s: %s", corosync_conf, e) def postproc(self): self.do_cmd_output_sub( |