summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSahina Bose <sabose@redhat.com>2014-04-11 12:08:22 +0530
committerBala.FA <barumuga@redhat.com>2014-04-29 10:21:37 +0530
commit4e1d15a964e5745a6ecea57082e4ce762fe96e98 (patch)
tree61c85ca68ae979e60f8bfae022d7c355ec0ed0c4
parent10c414706c2c77225c014673f03b8e3166b82ff2 (diff)
plugins: Added quota NRPE to volume status
Added a way to query for quota status to the check_vol_server plugin This will poll for quota status only if the service status for quota returns non-OK status Change-Id: I6260042ef54308a1f4f7b6d482a2b58a4682d36c Signed-off-by: Sahina Bose <sabose@redhat.com>
-rw-r--r--config/gluster-commands.cfg5
-rw-r--r--config/glustercluster.cfg.sample16
-rwxr-xr-xplugins/check_vol_server.py69
-rw-r--r--plugins/config_generator.py17
4 files changed, 79 insertions, 28 deletions
diff --git a/config/gluster-commands.cfg b/config/gluster-commands.cfg
index ec72417..c2fe324 100644
--- a/config/gluster-commands.cfg
+++ b/config/gluster-commands.cfg
@@ -75,3 +75,8 @@ define command {
command_name check_vol_status
command_line $USER1$/gluster/check_vol_server.py $ARG1$ $ARG2$ -o status
}
+
+define command {
+ command_name check_vol_quota_status
+ command_line $USER1$/gluster/check_vol_server.py $ARG1$ $ARG2$ -o quota
+}
diff --git a/config/glustercluster.cfg.sample b/config/glustercluster.cfg.sample
index 3afb95a..c7de065 100644
--- a/config/glustercluster.cfg.sample
+++ b/config/glustercluster.cfg.sample
@@ -108,6 +108,22 @@ define service{
}
################################################################################
+# This defines a Volume Quota status service
+# Edit this sample
+# host_name = the cluster host previously defined for cluster
+# service_description = Volume-status - <volname>
+# check_command = check_vol_status!<cluster-hostgroup-name>!<volume-name>
+# _VOL_NAME = Volume name
+################################################################################
+define service{
+ use gluster-service-without-graph
+ host_name test-cluster
+ service_description Volume Status Quota - data-vol
+ _VOL_NAME data-vol ; MUST DECLARE the custom var _VOL_NAME
+ check_command check_vol_quota_status!test-cluster!data-vol
+}
+
+################################################################################
# This defines a Cluster utilization service
# Edit this sample
# host_name = cluster host previously defined. (The service is under a cluster)
diff --git a/plugins/check_vol_server.py b/plugins/check_vol_server.py
index 87ca269..d784e94 100755
--- a/plugins/check_vol_server.py
+++ b/plugins/check_vol_server.py
@@ -23,22 +23,26 @@ def _getListHosts(args):
def _getHostAddress(host):
# Get the address of the host
host_address = livestatus.checkLiveStatus("GET hosts\nColumns: address\n"
- "Filter: display_name = "
- + host + "\n")
+ "Filter: display_name = "
+ + host + "\n")
return host_address.rstrip()
def _getVolUtilizationNRPECommand(args):
return ("check_vol_utilization -a " + args.volume + " " +
- str(args.warning) + " " + str(args.critical))
+ str(args.warning) + " " + str(args.critical))
def _getVolStatusNRPECommand(args):
return ("check_vol_status -a " + args.volume)
+def _getVolQuotaStatusNRPECommand(args):
+ return ("check_vol_quota_status -a " + args.volume)
+
+
def _getNRPEBaseCmd(host):
- return _NRPEPath + " -H " + host + " -c ";
+ return _NRPEPath + " -H " + host + " -c "
def execNRPECommand(command):
@@ -46,43 +50,53 @@ def execNRPECommand(command):
return os.WEXITSTATUS(status), output
-def showVolumeOutput(args):
+def _getVolumeQuotaStatusOutput(args):
+ # get current volume quota status
+ table = livestatus.checkLiveStatus("GET services\n"
+ "Columns: status plugin_output\n"
+ "Filter: service_description = "
+ "Volume Status Quota - " + args.volume)
+ servicestatus = table[0]
+ statusoutput = table[1]
+ if (servicestatus == utils.PluginStatusCode.OK and
+ statusoutput.find("QUOTA: OK") > -1):
+ # if ok, don't poll
+ return servicestatus, statusoutput
+ return _executeRandomHost(_getVolQuotaStatusNRPECommand(args))
+
+
+def _executeRandomHost(command):
list_hosts = _getListHosts(args)
host = random.choice(list_hosts)
#Get the address of the host
host_address = _getHostAddress(host)
- if args.option == 'status':
- command = _getVolStatusNRPECommand(args)
- elif args.option == 'utilization':
- command = _getVolUtilizationNRPECommand(args)
-
status, output = execNRPECommand(_getNRPEBaseCmd(host_address) + command)
if status != utils.PluginStatusCode.UNKNOWN:
return status, output
+ #random host is not able to execute the command
+ #Now try to iterate through the list of hosts
+ #in the host group and send the command until
+ #the command is successful
for host in list_hosts:
status, output = execNRPECommand(_getNRPEBaseCmd(_getHostAddress(host))
+ command)
if status != utils.PluginStatusCode.UNKNOWN:
return status, output
- break
return status, output
- #if success return from here
- if "Volume Utilization" in output:
- return status, output
- #radom host is not able to execute the command
- #Now try to iterate through the list of hosts
- #in the host group and send the command until
- #the command is successful
- for host in list_hosts:
- status, output = execNRPECommand(host, args)
- #if success return from here
- if "Volume Utilization" in output:
- return status, output
- break
- return status, output
+
+def showVolumeOutput(args):
+
+ if args.option == 'status':
+ command = _getVolStatusNRPECommand(args)
+ elif args.option == 'utilization':
+ command = _getVolUtilizationNRPECommand(args)
+ elif args.option == 'quota':
+ return _getVolumeQuotaStatusOutput(args)
+
+ return _executeRandomHost(command)
def parse_input():
@@ -113,7 +127,8 @@ def parse_input():
action='store',
help='the volume option to check',
choices=['utilization',
- 'status'])
+ 'status',
+ 'quota'])
args = parser.parse_args()
if args.critical <= args.warning:
print "UNKNOWN:Critical must be greater than Warning."
@@ -123,5 +138,5 @@ def parse_input():
if __name__ == '__main__':
args = parse_input()
status, output = showVolumeOutput(args)
- print output
+ print (output)
exit(status)
diff --git a/plugins/config_generator.py b/plugins/config_generator.py
index 9941028..02c5f67 100644
--- a/plugins/config_generator.py
+++ b/plugins/config_generator.py
@@ -73,7 +73,7 @@ class GlusterNagiosConfManager:
def __createVolumeStatusService(self, volume, clusterName):
volumeService = {}
volumeService['host_name'] = clusterName
- volumeService['use'] = 'gluster-service-withoout-graph'
+ volumeService['use'] = 'gluster-service-without-graph'
serviceDesc = 'Volume Status - %s' % (volume['name'])
volumeService['service_description'] = serviceDesc
volumeService['_VOL_NAME'] = volume['name']
@@ -83,6 +83,18 @@ class GlusterNagiosConfManager:
volumeService['notes'] = "Volume type : %s" % (volume['typeStr'])
return volumeService
+ def __createVolumeQuotaStatusService(self, volume, clusterName):
+ volumeService = {}
+ volumeService['host_name'] = clusterName
+ volumeService['use'] = 'gluster-service-without-graph'
+ serviceDesc = 'Volume Status Quota - %s' % (volume['name'])
+ volumeService['service_description'] = serviceDesc
+ volumeService['_VOL_NAME'] = volume['name']
+ checkCommand = 'check_vol_quota_status!%s!%s' % \
+ (clusterName, volume['name'])
+ volumeService['check_command'] = checkCommand
+ return volumeService
+
def createClusterUtilizationService(self, clusterName):
service = {}
service['host_name'] = clusterName
@@ -106,6 +118,9 @@ class GlusterNagiosConfManager:
volumeService = self.__createVolumeUtilizationService(volume,
clusterName)
volumeServices.append(volumeService)
+ volumeService = self.__createVolumeQuotaStatusService(volume,
+ clusterName)
+ volumeServices.append(volumeService)
return volumeServices
def __createBrickUtilizationService(self, brick, hostName):