summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishanth Thomas <nthomas@redhat.com>2014-05-01 20:46:10 +0530
committerSahina Bose <sabose@redhat.com>2014-05-05 05:24:05 -0700
commit5726854fb2954740d5c7d742a5ad4947cb78532c (patch)
treefcfb9c51da0c16b8046560c81a4bab77e68df227
parent63f7ffadb466d914bd67d74bbde495e75367cfdb (diff)
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 <nthomas@redhat.com> Reviewed-on: http://review.gluster.org/7635 Reviewed-by: Kanagaraj M <kmayilsa@redhat.com> Tested-by: Nishanth Thomas <nishusemail@gmail.com> Reviewed-by: Sahina Bose <sabose@redhat.com>
-rwxr-xr-xglusternagios/storage.py34
1 files changed, 33 insertions, 1 deletions
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 ""