From d040cb45469d64fa7534247f9568b48b28114c3f Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Mon, 9 Jun 2014 16:02:51 +0530 Subject: server-plugin: To check if any vol has server side quorum Added a server side plugin to change status from Pending to OK/UNKNOWN depending on if volumes have server side quorum turned on Renamed service to ensure service definition gets updated on upgrades. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1106421 Change-Id: I1f1ca1dcf56872342ec8e25396a89163d22aedeb Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/8023 Reviewed-by: darshan n Reviewed-by: Ramesh N --- config/gluster-commands.cfg | 6 ++++++ config/gluster-templates.cfg | 7 +++++++ plugins/check_vol_server.py | 28 +++++++++++++++++++++++++++- plugins/config_generator.py | 5 +++-- tests/test_config_generator.py | 2 +- 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/config/gluster-commands.cfg b/config/gluster-commands.cfg index ac61fc5..b4df742 100644 --- a/config/gluster-commands.cfg +++ b/config/gluster-commands.cfg @@ -101,6 +101,12 @@ define command { command_line $USER1$/gluster/check_vol_server.py $ARG1$ $ARG2$ -o geo-rep } +# since no volume is required to query quorum status, dummy is passed +define command { + command_name check_quorum_status + command_line $USER1$/gluster/check_vol_server.py $HOSTNAME$ dummy -o quorum +} + define command{ command_name check_cluster_status command_line $USER1$/gluster/check_cluster_status.py $HOSTNAME$ diff --git a/config/gluster-templates.cfg b/config/gluster-templates.cfg index 2668e6d..b9e38da 100644 --- a/config/gluster-templates.cfg +++ b/config/gluster-templates.cfg @@ -54,6 +54,13 @@ define service { max_check_attempts 1 } +define service { + name gluster-passive-freshness-service + use gluster-passive-service + check_freshness 1 + freshness_threshold 3600 ;check freshness every 1 hour +} + define service { name gluster-brick-status-service use gluster-service diff --git a/plugins/check_vol_server.py b/plugins/check_vol_server.py index e7dd150..a45a24d 100755 --- a/plugins/check_vol_server.py +++ b/plugins/check_vol_server.py @@ -62,6 +62,10 @@ def _getVolGeoRepStatusNRPECommand(volume): return ("check_vol_status -a %s %s" % (volume, 'geo-rep')) +def _getQuorumStatusNRPECommand(): + return ("check_quorum_status") + + # This function gets the replica pairs # bricks - list of bricks in the volume # pair_index - nth pair of replica's needs to be returned @@ -199,6 +203,25 @@ def _getVolumeQuotaStatusOutput(hostgroup, volume): return _executeRandomHost(hostgroup, _getVolQuotaStatusNRPECommand(volume)) +def _getQuorumStatusOutput(hostgroup): + # get current volume quorum status + table = livestatus.readLiveStatus("GET services\n" + "Columns: state,plugin_output\n" + "Filter: description = " + "Cluster - Quorum\n" + "Filter: host_name = %s\n" % hostgroup) + servicestatus = utils.PluginStatusCode.UNKNOWN + pluginoutput = '' + if len(table) > 0: + servicetab = table[0] + servicestatus = servicetab[0] + pluginoutput = servicetab[1] + if (int(servicestatus) != utils.PluginStatusCode.CRITICAL): + return _executeRandomHost(hostgroup, _getQuorumStatusNRPECommand()) + else: + return servicestatus, pluginoutput + + def execNRPECommand(command): status, output, err = utils.execCmd(command.split(), raw=True) return status, output @@ -255,6 +278,8 @@ def showVolumeOutput(args): command = _getVolSelfHealStatusNRPECommand(args.volume) elif args.option == 'geo-rep': command = _getVolGeoRepStatusNRPECommand(args.volume) + elif args.option == 'quorum': + return _getQuorumStatusOutput(args.hostgroup) return _executeRandomHost(args.hostgroup, command) @@ -290,7 +315,8 @@ def parse_input(): 'status', 'quota', 'self-heal', - 'geo-rep']) + 'geo-rep', + 'quorum']) parser.add_argument('-t', '--timeout', action='store', help='NRPE timeout') diff --git a/plugins/config_generator.py b/plugins/config_generator.py index 62c39ce..64b093a 100644 --- a/plugins/config_generator.py +++ b/plugins/config_generator.py @@ -144,8 +144,9 @@ class GlusterNagiosConfManager: def createClusterQuorumService(self, clusterName): service = {} service['host_name'] = clusterName - service['use'] = 'gluster-passive-service' - service['service_description'] = 'Cluster - Quorum' + service['use'] = 'gluster-passive-freshness-service' + service['service_description'] = 'Cluster - Quorum Status' + service['check_command'] = 'check_quorum_status' return service def createClusterAutoConfigService(self, clusterName, hostIp): diff --git a/tests/test_config_generator.py b/tests/test_config_generator.py index 5a0294e..91fce1e 100644 --- a/tests/test_config_generator.py +++ b/tests/test_config_generator.py @@ -72,7 +72,7 @@ class TestGlusterNagiosConfManager(TestCaseBase): def _verifyClusterServices(self, clusterConfig, clusterData): totalServices = 0 services = clusterConfig[HOST_SERVICES] - self._checkServiceExists("Cluster - Quorum", services) + self._checkServiceExists("Cluster - Quorum Status", services) self._checkServiceExists(GLUSTER_AUTO_CONFIG, services) self._checkServiceExists("Cluster Utilization", services) -- cgit