summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorTimothy Asir <tjeyasin@redhat.com>2014-06-11 18:31:56 +0530
committerSahina Bose <sabose@redhat.com>2014-06-16 04:46:47 -0700
commitd89e8d4ba22635e49f9d6a9bb9fa740f26bb538d (patch)
treed431f2678f7b2fae6cc30be050610dc03371d0d8 /plugins
parentc408fed3cd1b960a53bbde75e842ff498de79420 (diff)
Remove python-psutil dependency
Change-Id: I6267242de480f4c7a572eeac7a74472bf7ab9226 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1103759 Signed-off-by: Timothy Asir <tjeyasin@redhat.com> Reviewed-on: http://review.gluster.org/8037 Tested-by: Timothy Asir <tim.gluster@gmail.com> Reviewed-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/check_proc_util.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/plugins/check_proc_util.py b/plugins/check_proc_util.py
index 3a1061b..af0b0e5 100755
--- a/plugins/check_proc_util.py
+++ b/plugins/check_proc_util.py
@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
+import os
import errno
-import psutil
from glusternagios import utils
@@ -49,6 +49,13 @@ class CtdbNodeStatus:
DISABLED = 'DISABLED'
+def _pidExists(pid):
+ if type(pid) is int and pid > 0:
+ return os.path.exists("/proc/%s" % pid)
+ else:
+ raise ValueError("invalid pid :%s" % pid)
+
+
def getBrickStatus(volumeName, brickName):
status = None
brickPath = brickName.split(':')[1]
@@ -56,18 +63,24 @@ def getBrickStatus(volumeName, brickName):
try:
with open("%s/%s/run/%s" % (
_glusterVolPath, volumeName, pidFile)) as f:
- if psutil.pid_exists(int(f.read().strip())):
- status = utils.PluginStatusCode.OK
- brickDevice = storage.getBrickDeviceName(brickPath)
- disk = storage.getDisksForBrick(brickDevice)
- cmd = [checkIdeSmartCmdPath.cmd, "-d", disk, "-n"]
- rc, out, err = utils.execCmd(cmd)
- if rc == utils.PluginStatusCode.CRITICAL and \
- "tests failed" in out[0]:
- status = utils.PluginStatusCode.WARNING
- msg = "WARNING: Brick %s: %s" % (brickPath, out[0])
- else:
+ try:
+ if _pidExists(int(f.read().strip())):
+ status = utils.PluginStatusCode.OK
+ brickDevice = storage.getBrickDeviceName(brickPath)
+ disk = storage.getDisksForBrick(brickDevice)
+ cmd = [checkIdeSmartCmdPath.cmd, "-d", disk, "-n"]
+ rc, out, err = utils.execCmd(cmd)
+ if rc == utils.PluginStatusCode.CRITICAL and \
+ "tests failed" in out[0]:
+ status = utils.PluginStatusCode.WARNING
+ msg = "WARNING: Brick %s: %s" % (brickPath, out[0])
+ else:
+ status = utils.PluginStatusCode.CRITICAL
+ except ValueError as e:
status = utils.PluginStatusCode.CRITICAL
+ msg = "Invalid pid of brick %s: %s" % (brickPath,
+ str(e))
+ return status, msg
except IOError as e:
if e.errno == errno.ENOENT:
status = utils.PluginStatusCode.CRITICAL