summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKanagaraj M <kmayilsa@redhat.com>2014-04-16 14:23:56 +0530
committerBala.FA <barumuga@redhat.com>2014-04-29 10:21:37 +0530
commit5307bc90561701c28ffcf26929e67c576f1c5b31 (patch)
tree916dd172920a29c5f7ec32cc3b7549de1d09e557 /plugins
parent4576bf0d0d8c63219960d6c7b545bca94d7cacd9 (diff)
vol-status: check for brick statuses
When a volume is in Up state, Volume status will be decided based on the status of the bricks. CRITICAL - If all bricks are in CRITICAL state WARNING - If some bricks are in CRITICAL state OK - If all bricks are in OK state Change-Id: Id90f8a5b1e0aaaa1de488b4356efbdd45fa43b7b Signed-off-by: Kanagaraj M <kmayilsa@redhat.com>
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/check_vol_server.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/plugins/check_vol_server.py b/plugins/check_vol_server.py
index e8e8522..34adf92 100755
--- a/plugins/check_vol_server.py
+++ b/plugins/check_vol_server.py
@@ -1,13 +1,14 @@
#!/usr/bin/python
import sys
import commands
+import json
import random
import argparse
import livestatus
import os
-from glusternagios import utils
-_NRPEPath = "/usr/lib64/nagios/plugins/check_nrpe"
+from glusternagios import utils
+from constants import NRPE_PATH
def _getListHosts(args):
@@ -42,7 +43,7 @@ def _getVolQuotaStatusNRPECommand(args):
def _getNRPEBaseCmd(host):
- return _NRPEPath + " -H " + host + " -c "
+ return NRPE_PATH + " -H " + host + " -c "
def execNRPECommand(command):
@@ -50,6 +51,40 @@ def execNRPECommand(command):
return os.WEXITSTATUS(status), output
+def _getVolumeStatusOutput(args):
+ status, output_text = _executeRandomHost(_getVolStatusNRPECommand(args))
+
+ output = output_text
+ # If status OK, volume info will be available as part of the output
+ if status == utils.PluginStatusCode.OK:
+ lines = output_text.split('\n')
+ if len(lines) > 1:
+ output = lines[0]
+ volumes = json.loads(lines[1])
+ volume = volumes[args.volume]
+ criticalBricks = 0
+ for brick in volume['bricks']:
+ brick_status = livestatus.checkLiveStatus(
+ "GET services\n"
+ "Columns: state\n"
+ "Filter: description = "
+ "Brick Status - %s\n"
+ % brick)
+ if brick_status and brick_status.strip():
+ servicestatus = brick_status.strip()
+ if int(servicestatus) == utils.PluginStatusCode.CRITICAL:
+ criticalBricks += 1
+
+ if criticalBricks > 0:
+ if volume['brickCount'] == criticalBricks:
+ status = utils.PluginStatusCode.CRITICAL
+ output = "All the bricks are in CRITICAL state"
+ else:
+ status = utils.PluginStatusCode.WARNING
+ output = "One or more bricks are in CRITICAL state"
+ return status, output
+
+
def _getVolumeQuotaStatusOutput(args):
# get current volume quota status
table = livestatus.readLiveStatus("GET services\n"
@@ -94,7 +129,7 @@ def _executeRandomHost(command):
def showVolumeOutput(args):
if args.option == 'status':
- command = _getVolStatusNRPECommand(args)
+ return _getVolumeStatusOutput(args)
elif args.option == 'utilization':
command = _getVolUtilizationNRPECommand(args)
elif args.option == 'quota':