From d5f6c2145bb37d7607d3f05329c0efca3c398fae Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Thu, 24 Apr 2014 16:35:27 +0530 Subject: plugins: Server side plugin for geo-rep Added server side plugin option for geo-rep status Change-Id: I6f604862ec7d4813298a670b7ed2cc0b448faf23 Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/7592 --- config/gluster-commands.cfg | 5 +++++ config/glustercluster.cfg.sample | 16 ++++++++++++++++ plugins/check_vol_server.py | 9 ++++++++- plugins/config_generator.py | 16 ++++++++++++++++ tests/test_config_generator.py | 6 +++++- 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/config/gluster-commands.cfg b/config/gluster-commands.cfg index 196ca08..9c3e386 100644 --- a/config/gluster-commands.cfg +++ b/config/gluster-commands.cfg @@ -96,6 +96,11 @@ define command { command_line $USER1$/gluster/check_vol_server.py $ARG1$ $ARG2$ -o self-heal } +define command { + command_name check_vol_georep_status + command_line $USER1$/gluster/check_vol_server.py $ARG1$ $ARG2$ -o geo-rep +} + 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 adf823d..e8d73c1 100644 --- a/config/glustercluster.cfg.sample +++ b/config/glustercluster.cfg.sample @@ -142,6 +142,22 @@ define service{ check_command check_vol_heal_status!test-cluster!data-vol } +################################################################################ +# This defines a Volume Geo Replication status service +# Edit this sample +# host_name = the cluster host previously defined for cluster +# service_description = Volume Geo-Replication - +# check_command = check_vol_georep_status!! +# _VOL_NAME = Volume name +################################################################################ +define service{ + use gluster-service-without-graph + host_name test-cluster + service_description Volume Geo-Replication - data-vol + _VOL_NAME data-vol ; MUST DECLARE the custom var _VOL_NAME + check_command check_vol_georep_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 4e99eb6..1cc043f 100755 --- a/plugins/check_vol_server.py +++ b/plugins/check_vol_server.py @@ -46,6 +46,10 @@ def _getVolSelfHealStatusNRPECommand(args): return ("check_vol_status -a %s %s" % (args.volume, 'self-heal')) +def _getVolGeoRepStatusNRPECommand(args): + return ("check_vol_status -a %s %s" % (args.volume, 'geo-rep')) + + def _getNRPEBaseCmd(host): return NRPE_PATH + " -H " + host + " -c " @@ -140,6 +144,8 @@ def showVolumeOutput(args): return _getVolumeQuotaStatusOutput(args) elif args.option == 'self-heal': command = _getVolSelfHealStatusNRPECommand(args) + elif args.option == 'geo-rep': + command = _getVolGeoRepStatusNRPECommand(args) return _executeRandomHost(command) @@ -174,7 +180,8 @@ def parse_input(): choices=['utilization', 'status', 'quota', - 'self-heal']) + 'self-heal', + 'geo-rep']) 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 e7d35fd..d90c5ae 100644 --- a/plugins/config_generator.py +++ b/plugins/config_generator.py @@ -108,6 +108,18 @@ class GlusterNagiosConfManager: volumeService['check_command'] = checkCommand return volumeService + def __createVolumeGeoRepStatusService(self, volume, clusterName): + volumeService = {} + volumeService['host_name'] = clusterName + volumeService['use'] = 'gluster-service-without-graph' + serviceDesc = 'Volume Geo-Replication - %s' % (volume['name']) + volumeService['service_description'] = serviceDesc + volumeService['_VOL_NAME'] = volume['name'] + checkCommand = 'check_vol_georep_status!%s!%s' % \ + (clusterName, volume['name']) + volumeService['check_command'] = checkCommand + return volumeService + def createClusterUtilizationService(self, clusterName): service = {} service['host_name'] = clusterName @@ -140,6 +152,10 @@ class GlusterNagiosConfManager: __createVolumeHealStatusService(volume, clusterName)) volumeServices.append(volumeService) + volumeService = (self. + __createVolumeGeoRepStatusService(volume, + clusterName)) + volumeServices.append(volumeService) volumeService = self.__createVolumeStatusService(volume, clusterName) volumeServices.append(volumeService) diff --git a/tests/test_config_generator.py b/tests/test_config_generator.py index d8e8789..ea41e7d 100644 --- a/tests/test_config_generator.py +++ b/tests/test_config_generator.py @@ -65,7 +65,7 @@ class TestGlusterNagiosConfManager(TestCaseBase): self._verifyClusterServices(config, clusterData) def _verifyClusterServices(self, clusterConfig, clusterData): - self.assertEqual(len(clusterConfig['host_services']), 6) + self.assertEqual(len(clusterConfig['host_services']), 7) for volume in clusterData['volumes']: self._verifyVolumeServices(clusterConfig['host_services'], volume) @@ -82,6 +82,10 @@ class TestGlusterNagiosConfManager(TestCaseBase): service = self._findServiceInList(serviceList, serviceDesc) self.assertNotEqual(service, None, "Volume Status Quota service is not created") + serviceDesc = 'Volume Geo-Replication - %s' % (volume['name']) + service = self._findServiceInList(serviceList, serviceDesc) + self.assertNotEqual(service, None, + "Volume Geo-Replication service is not created") if 'Replicate' in volume['type']: serviceDesc = 'Volume Self-Heal - %s' % (volume['name']) service = self._findServiceInList(serviceList, serviceDesc) -- cgit