diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2012-12-06 20:48:42 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2012-12-06 20:48:42 +0000 |
commit | 6c6bb99cb7bdab2536f88e25933c3c6c54774ab9 (patch) | |
tree | 8711e52102b01482bb678ae3507dc56166b5378c | |
parent | 89ee04e8f71b2dd19ad1d7b9ae16c68f33b85389 (diff) | |
download | sos-6c6bb99cb7bdab2536f88e25933c3c6c54774ab9.tar.gz |
Fix exception when sar module enabled on system without sysstat
The sar module assumes that /var/log/sa exists when it is enabled.
Check for its presence and exit from setup early.
-rw-r--r-- | sos/plugins/sar.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sos/plugins/sar.py b/sos/plugins/sar.py index 1f52a84b..687ae4e8 100644 --- a/sos/plugins/sar.py +++ b/sos/plugins/sar.py @@ -13,7 +13,7 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin -from os import listdir +import os class sar(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): """Generate the sar file from /var/log/sa/saXX files @@ -22,8 +22,10 @@ class sar(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): files = ('/var/log/sa', '/usr/bin/sar') def setup(self): - path="/var/log/sa" - dirList=listdir(path) + sapath="/var/log/sa" + if not os.path.exists(sapath): + return + dirList=listdir(sapath) # 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': |