summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShireesh Anjal <anjalshireesh@gmail.com>2011-08-04 02:05:22 -0700
committerShireesh Anjal <anjalshireesh@gmail.com>2011-08-04 02:05:22 -0700
commit8e8dcb7bbd179a8f50dfe04c5844b8f0fff931bb (patch)
tree80f0bd3ad22c0652b432d895412c28407057dff2
parent444ee2cd62b20375d1e06e076dd686308bd9b31d (diff)
parentc024c9197fbe46fcf988740e8379b34267eceb24 (diff)
Merge pull request #191 from TimothyAsir/master
Enhanced get_server_details.py to provide disk-space-in-use using df command in case of HAL failed to give.
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/DiskUtils.py14
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/Utils.py6
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py18
3 files changed, 20 insertions, 18 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/DiskUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/DiskUtils.py
index a0e5d802..aa77cebb 100644
--- a/src/com.gluster.storage.management.gateway.scripts/src/DiskUtils.py
+++ b/src/com.gluster.storage.management.gateway.scripts/src/DiskUtils.py
@@ -256,7 +256,17 @@ def getDiskInfo(diskDeviceList=None):
disk["FsVersion"] = None
disk["MountPoint"] = None
disk["ReadOnlyAccess"] = None
- disk["SpaceInUse"] = None
+
+ spaceInUse = None
+ rv = Utils.runCommand("df %s" % (disk["Device"]), output=True, root=True)
+ if rv["Status"] == 0:
+ try:
+ spaceInUse = long(rv["Stdout"].split("\n")[1].split()[2]) / 1024
+ except IndexError:
+ pass
+ except ValueError:
+ pass
+ disk["SpaceInUse"] = spaceInUse
partitionUdiList = halManager.FindDeviceStringMatch("info.parent", udi)
if isDiskInFormatting(disk["Device"]):
@@ -315,7 +325,7 @@ def getDiskInfo(diskDeviceList=None):
disk["ReadOnlyAccess"] = str(partitionHalDevice.GetProperty('volume.is_mounted_read_only'))
if not disk["Size"]:
disk["Size"] = long(partitionHalDevice.GetProperty('volume.size')) / 1024**2
- disk["SpaceInUse"] = used
+ #disk["SpaceInUse"] = used
continue
partition = {}
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/Utils.py b/src/com.gluster.storage.management.gateway.scripts/src/Utils.py
index 980e7937..a212f104 100644
--- a/src/com.gluster.storage.management.gateway.scripts/src/Utils.py
+++ b/src/com.gluster.storage.management.gateway.scripts/src/Utils.py
@@ -409,7 +409,11 @@ def getCpuUsageAvg():
if not (st1 and st2):
return None
delta = [st2[i] - st1[i] for i in range(len(st1))]
- cpuPercent = sum(delta[:3]) / delta[3] * 100.0
+ try:
+ cpuPercent = sum(delta[:3]) / delta[3] * 100.0
+ except ZeroDivisionError, e:
+ log("failed to find cpu percentage:%s" % str(e))
+ return None
return str('%.4f' % cpuPercent)
def getLoadavg():
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py
index 8d2efd1a..e60d7199 100755
--- a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py
+++ b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py
@@ -1,20 +1,8 @@
#!/usr/bin/python
-# Copyright (C) 2010 Gluster, Inc. <http://www.gluster.com>
-# This file is part of Gluster Storage Platform.
+# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com>
+# This file is part of Gluster Management Gateway.
#
-# Gluster Storage Platform is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 3 of
-# the License, or (at your option) any later version.
-#
-# Gluster Storage Platform is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
+
import os
import sys
p1 = os.path.abspath(os.path.dirname(sys.argv[0]))