summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/check_vol_server.py69
-rw-r--r--plugins/config_generator.py17
2 files changed, 58 insertions, 28 deletions
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):