From 89db997887f8b993fd5fcc68860b7c7f09732076 Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Mon, 21 Apr 2014 17:36:08 +0530 Subject: plugins: Server side plugin for self-heal Server side plugin to check the volume self heal status Change-Id: Ia1ee3fb653913360edb1b54b42cce3ed105bdb79 Signed-off-by: Sahina Bose --- config/gluster-commands.cfg | 5 +++++ config/glustercluster.cfg.sample | 18 +++++++++++++++++- plugins/check_vol_server.py | 9 ++++++++- plugins/config_generator.py | 17 +++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/config/gluster-commands.cfg b/config/gluster-commands.cfg index 60d6757..57b76ce 100644 --- a/config/gluster-commands.cfg +++ b/config/gluster-commands.cfg @@ -91,6 +91,11 @@ define command { command_line $USER1$/gluster/check_vol_server.py $ARG1$ $ARG2$ -o quota } +define command { + command_name check_vol_heal_status + command_line $USER1$/gluster/check_vol_server.py $ARG1$ $ARG2$ -o self-heal +} + define command{ command_name check_cluster_status command_line $USER1$/gluster/check_cluster_status.py $HOSTNAME$ diff --git a/config/glustercluster.cfg.sample b/config/glustercluster.cfg.sample index d51688d..191b6ee 100644 --- a/config/glustercluster.cfg.sample +++ b/config/glustercluster.cfg.sample @@ -111,7 +111,7 @@ define service{ # Edit this sample # host_name = the cluster host previously defined for cluster # service_description = Volume-status - -# check_command = check_vol_status!! +# check_command = check_vol_quota_status!! # _VOL_NAME = Volume name ################################################################################ define service{ @@ -122,6 +122,22 @@ define service{ check_command check_vol_quota_status!test-cluster!data-vol } +################################################################################ +# This defines a Volume Self Heal status service +# Edit this sample +# host_name = the cluster host previously defined for cluster +# service_description = Volume Self-Heal - +# check_command = check_vol_heal_status!! +# _VOL_NAME = Volume name +################################################################################ +define service{ + use gluster-service-without-graph + host_name test-cluster + service_description Volume Self-Heal - data-vol + _VOL_NAME data-vol ; MUST DECLARE the custom var _VOL_NAME + check_command check_vol_heal_status!test-cluster!data-vol +} + ################################################################################ # This defines a Cluster utilization service # Edit this sample diff --git a/plugins/check_vol_server.py b/plugins/check_vol_server.py index f780ba8..8e42126 100755 --- a/plugins/check_vol_server.py +++ b/plugins/check_vol_server.py @@ -42,6 +42,10 @@ def _getVolQuotaStatusNRPECommand(args): return ("check_vol_quota_status -a " + args.volume) +def _getVolSelfHealStatusNRPECommand(args): + return ("check_vol_heal_status -a " + args.volume) + + def _getNRPEBaseCmd(host): return NRPE_PATH + " -H " + host + " -c " @@ -134,6 +138,8 @@ def showVolumeOutput(args): command = _getVolUtilizationNRPECommand(args) elif args.option == 'quota': return _getVolumeQuotaStatusOutput(args) + elif args.option == 'self-heal': + command = _getVolSelfHealStatusNRPECommand(args) return _executeRandomHost(command) @@ -167,7 +173,8 @@ def parse_input(): help='the volume option to check', choices=['utilization', 'status', - 'quota']) + 'quota', + 'self-heal']) args = parser.parse_args() if args.critical <= args.warning: print "UNKNOWN:Critical must be greater than Warning." diff --git a/plugins/config_generator.py b/plugins/config_generator.py index 6ba1631..d383b0b 100644 --- a/plugins/config_generator.py +++ b/plugins/config_generator.py @@ -96,6 +96,18 @@ class GlusterNagiosConfManager: volumeService['notes'] = "Volume type : %s" % (volume['type']) return volumeService + def __createVolumeHealStatusService(self, volume, clusterName): + volumeService = {} + volumeService['host_name'] = clusterName + volumeService['use'] = 'gluster-service-without-graph' + serviceDesc = 'Volume Self-Heal - %s' % (volume['name']) + volumeService['service_description'] = serviceDesc + volumeService['_VOL_NAME'] = volume['name'] + checkCommand = 'check_vol_heal_status!%s!%s' % \ + (clusterName, volume['name']) + volumeService['check_command'] = checkCommand + return volumeService + def createClusterUtilizationService(self, clusterName): service = {} service['host_name'] = clusterName @@ -122,6 +134,11 @@ class GlusterNagiosConfManager: volumeService = self.__createVolumeQuotaStatusService(volume, clusterName) volumeServices.append(volumeService) + if 'Replicate' in volume['type']: + volumeService = (self. + __createVolumeHealStatusService(volume, + clusterName)) + volumeServices.append(volumeService) volumeService = self.__createVolumeStatusService(volume, clusterName) volumeServices.append(volumeService) -- cgit