summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/gluster-commands.cfg6
-rw-r--r--config/gluster-templates.cfg7
-rwxr-xr-xplugins/check_vol_server.py28
-rw-r--r--plugins/config_generator.py5
-rw-r--r--tests/test_config_generator.py2
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
@@ -55,6 +55,13 @@ define service {
}
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
register 0
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)