From 86b4152f7a4b53b82d07f6f3269b73dee378bc44 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Tue, 11 Sep 2012 18:30:39 +0530 Subject: [PATCH] plugins/gluster: changes in gluster plugin for sosreport * Do not execute volume status commands to get the information about inode table, fd etc. Instead collect statedump of all the glusterfs processes by issuing SIGUSR1, and include the statedump files in the sosreport. Signed-off-by: Raghavendra Bhat --- sos/plugins/gluster.py | 57 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/sos/plugins/gluster.py b/sos/plugins/gluster.py index 2036fa9..1a7f586 100644 --- a/sos/plugins/gluster.py +++ b/sos/plugins/gluster.py @@ -12,12 +12,17 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +import time import os.path import sos.plugintools +import os +import string class gluster(sos.plugintools.PluginBase): '''gluster related information''' + statedump_dir = '/tmp/glusterfs-statedumps' + def defaultenabled(self): return True @@ -41,6 +46,35 @@ class gluster(sos.plugintools.PluginBase): or os.path.exists("/var/lib/glusterd") \ or sos.plugintools.PluginBase.checkenabled(self) + def make_preparations(self, name_dir): + try: + os.mkdir(name_dir); + except: + pass + fp = open ('/tmp/glusterdump.options', 'w'); + data = 'path=' + name_dir + '\n'; + fp.write(data); + fp.write('all=yes'); + fp.close(); + + def wait_for_statedump(self, name_dir): + statedumps_present = 0; + statedump_entries = os.listdir(name_dir); + for statedump_file in statedump_entries: + statedumps_present = statedumps_present+1; + last_line = 'tmp'; + ret = -1; + while ret == -1: + last_line = file(name_dir + '/' + statedump_file, "r").readlines()[-1]; + ret = string.count (last_line, 'DUMP_END_TIME'); + + def postproc(self): + for dirs in os.listdir(self.statedump_dir): + os.remove(self.statedump_dir + '/' + dirs); + + os.rmdir(self.statedump_dir); + os.unlink('/tmp/glusterdump.options'); + def setup(self): self.collectExtOutput("/usr/sbin/gluster peer status") @@ -67,20 +101,17 @@ class gluster(sos.plugintools.PluginBase): # common to all versions self.addCopySpec("/etc/glusterfs") - # This will fail on <3.3.x but has no harmful side-effects - volume_file = self.collectOutputNow("/usr/sbin/gluster volume info", - "gluster_volume_info") - if volume_file: - for volname in self.get_volume_names(volume_file): - self.collectExtOutput("gluster volume statedump %s" % volname) - self.collectExtOutput("gluster volume statedump %s nfs" % volname) - self.collectExtOutput("gluster volume status %s detail" % volname) - self.collectExtOutput("gluster volume status %s clients" % volname) - self.collectExtOutput("gluster volume status %s mem" % volname) - self.collectExtOutput("gluster volume status %s callpool" % volname) - self.collectExtOutput("gluster volume status %s inode" % volname) - self.collectExtOutput("gluster volume status %s fd" % volname) + self.make_preparations(self.statedump_dir) + #self.collectExtOutput("killall -USR1 glusterfs glusterfsd") + os.system("killall -USR1 glusterfs glusterfsd"); + # let all the processes catch the signal and create statedump file + # entries. + time.sleep(1) + self.wait_for_statedump(self.statedump_dir) + self.addCopySpec('/tmp/glusterdump.options') + self.addCopySpec(self.statedump_dir) self.collectExtOutput("gluster volume status") # collect this last as some of the other actions create log entries self.addCopySpec("/var/log/glusterfs") + -- 1.7.10.4