From c61d0ac3331f218ba39ade7a6c9ade82a3990ed8 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 19 Jun 2014 17:19:58 +0100 Subject: [PATCH] [gluster] update plugin and add log file size-limiting --- sos/plugins/gluster.py | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/sos/plugins/gluster.py b/sos/plugins/gluster.py index 9bf427e..fa3de97 100644 --- a/sos/plugins/gluster.py +++ b/sos/plugins/gluster.py @@ -21,11 +21,14 @@ import string class gluster(sos.plugintools.PluginBase): '''gluster related information''' - statedump_dir = '/sos_commands/gluster/glusterfs-statedumps' - master_statedump_dir = '/sos_commands' + optionList = [("logsize", "max log size (MiB) to collect", "", 5), + ("all_logs", "collect all log files present", "", False)] + + packages = ('glusterfs', 'glusterfs-core') + files = ('/etc/glusterd', '/var/lib/glusterd') - def defaultenabled(self): - return True + statedump_dir = '/tmp/glusterfs-statedumps' + master_statedump_dir = '/sos_commands' def get_volume_names(self, volume_file): """Return a dictionary for which key are volume names according to the @@ -41,12 +44,6 @@ class gluster(sos.plugintools.PluginBase): fp.close() return out - def checkenabled(self): - packages = ["glusterfs", "glusterfs-core"] - return os.path.exists("/etc/glusterd") \ - or os.path.exists("/var/lib/glusterd") \ - or sos.plugintools.PluginBase.checkenabled(self) - def make_preparations(self, name_dir): try: os.makedirs(name_dir); @@ -121,6 +118,25 @@ class gluster(sos.plugintools.PluginBase): self.collectExtOutput("gluster volume geo-replication %s status" % volname) self.collectExtOutput("gluster volume status") - # collect this last as some of the other actions create log entries - self.addCopySpec("/var/log/glusterfs") + + # all_logs takes precedence over logsize + if not self.getOption("all_logs"): + limit = self.getOption("logsize") + else: + limit = 0 + + if limit: + # collect logs last as some of the other actions create log entries + self.addCopySpecLimit("/var/log/glusterfs/cli.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/*.vol.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/gluster-lock.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/glustershd.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/nfs.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/quota-crawl.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/quotad.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/quotad-mount-*.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/status.log", limit) + self.addCopySpecLimit("/var/log/glusterfs/bricks/*.log", limit) + else: + self.addCopySpec("/var/log/glusterfs") -- 1.9.3