From 5726854fb2954740d5c7d742a5ad4947cb78532c Mon Sep 17 00:00:00 2001 From: Nishanth Thomas Date: Thu, 1 May 2014 20:46:10 +0530 Subject: gluster-nagios-common: check disk status along with brick status Modifed the storage utils to add the utility functions check the disk status Change-Id: If4eac75451071456876a858e2bc4d2d262a9e451 Signed-off-by: Nishanth Thomas Reviewed-on: http://review.gluster.org/7635 Reviewed-by: Kanagaraj M Tested-by: Nishanth Thomas Reviewed-by: Sahina Bose --- glusternagios/storage.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'glusternagios') diff --git a/glusternagios/storage.py b/glusternagios/storage.py index 3371d4e..1147d25 100755 --- a/glusternagios/storage.py +++ b/glusternagios/storage.py @@ -31,6 +31,7 @@ vgsCmdPath = CommandPath("vgs", ) pvsCmdPath = CommandPath("pvs", "/sbin/pvs") +dfCmdPath = CommandPath("df", "/bin/df") # Class for exception definition @@ -97,6 +98,18 @@ def _getLvDetailsCmd(): "vg_name,pv_name,lv_name").split() +def _getdfDetailsCmd(brickName): + return [dfCmdPath.cmd] + (" -ah " + brickName).split() + + +def getdf(brickName): + rc, out, err = utils.execCmd(_getdfDetailsCmd(brickName)) + if rc: + raise ExecCmdFailedException(err=[str(err)]) + + return out + + # Gets the list of logical volumes def getLvs(): rc, out, err = utils.execCmd(_getLvsCmd()) @@ -235,7 +248,9 @@ def _getBrickDeviceName(brickName): # Gets the list of disks participating in the given brick -def getDisksForBrick(brickName, deviceName=None): +def getDisksForBrick(deviceName=None, brickName=None): + if brickName is None and deviceName is None: + return "" # Get the brick device name if deviceName is None: deviceName = _getBrickDeviceName(brickName) @@ -251,3 +266,20 @@ def getDisksForBrick(brickName, deviceName=None): return lv_dict[key]['LVM2_PV_NAME'] return "" + + +#gets the brick's device name using df command +def getBrickDeviceName(brickName): + brickName = brickName.rstrip() + if brickName is "": + return "" + dfOut = getdf(brickName) + #The output will be similar to + #['Filesystem Size Used Avail Use% Mounted on', + # '/dev/vda1 485M 34M 426M 8% /boot'] + #need to parse to get the device name + if len(dfOut) > 1: + dfOutList = dfOut[1].split() + if len(dfOutList) > 0: + return dfOutList[0] + return "" -- cgit