commit e53f06e9a50b16a204d27049b83c3a32505a4ab6 Author: Bryn M. Reeves Date: Thu Nov 7 17:48:03 2013 +0000 Fix traceback when sar module is force-enabled Forward port of the following sos-2.2 fix: commit d4e3bcc3ed247d8d9a1228c3661b6456f534daf4 Author: Bryn M. Reeves Date: Mon Aug 12 18:42:48 2013 +0100 Fix traceback when sar module is force-enabled The sar plug-in assumes that when it runs the /var/lib/sa directory and binaries exist (they are part of checkenabled() for this module). This leads to a traceback when the plug-in lists a non-existent directory on hosts where sar is not installed but '-o sar' is specified on the command line. Catch the exception and exit gracefully. (Edited by bmr to improve error message logged). Signed-off-by: David Kutálek Signed-off-by: Bryn M. Reeves diff --git a/sos/plugins/sar.py b/sos/plugins/sar.py index 4f89b53..570262a 100644 --- a/sos/plugins/sar.py +++ b/sos/plugins/sar.py @@ -43,8 +43,12 @@ class Sar(Plugin,): self.add_copy_spec_limit("/var/log/sa/sar[0-9]*", sizelimit = self.sa_size) self.add_copy_spec_limit("/var/log/sa/sa[0-9]*", - sizelimit = self.sa_size) - dirList = os.listdir(self.sa_path) + sizelimit = self.sa_size) + try: + dirList = os.listdir(self.sa_path) + except: + self.soslog.error("sar: could not list /var/log/sa") + return # find all the sa file that don't have an existing sar file for fname in dirList: if fname[0:2] == 'sa' and fname[2] != 'r':