summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gluster-nagios-addons.spec.in1
-rwxr-xr-xplugins/check_proc_util.py37
2 files changed, 25 insertions, 13 deletions
diff --git a/gluster-nagios-addons.spec.in b/gluster-nagios-addons.spec.in
index 0ae3bed..885a641 100644
--- a/gluster-nagios-addons.spec.in
+++ b/gluster-nagios-addons.spec.in
@@ -84,7 +84,6 @@ Requires: python-inotify
Requires: python-netaddr
Requires: python-pthreading
Requires: python-cpopen >= 1.3
-Requires: python-psutil
Requires: python-lockfile
Requires: python-daemon
Requires: sysstat
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