summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gluster-nagios-addons.spec.in1
-rwxr-xr-xplugins/check_volume_status.py33
-rw-r--r--tests/test_check_volume_status.py20
3 files changed, 53 insertions, 1 deletions
diff --git a/gluster-nagios-addons.spec.in b/gluster-nagios-addons.spec.in
index 9406bce..794109c 100644
--- a/gluster-nagios-addons.spec.in
+++ b/gluster-nagios-addons.spec.in
@@ -144,6 +144,7 @@ command[check_vol_utilization]=sudo %{_libdir}/nagios/plugins/gluster/check_vol_
command[check_vol_status]=sudo %{_libdir}/nagios/plugins/gluster/check_volume_status.py -v \$ARG1\$ -t info
command[check_vol_quota_status]=sudo %{_libdir}/nagios/plugins/gluster/check_volume_status.py -v \$ARG1\$ -t quota
command[check_vol_heal_status]=sudo %{_libdir}/nagios/plugins/gluster/check_volume_status.py -v \$ARG1\$ -t self-heal
+command[check_vol_heal_status]=sudo %{_libdir}/nagios/plugins/gluster/check_volume_status.py -v \$ARG1\$ -t geo-rep
###Auto Discovery related
command[discoverpeers]=sudo %{_libdir}/nagios/plugins/gluster/discoverpeers.py
command[discoverlogicalcomponents]=sudo %{_libdir}/nagios/plugins/gluster/discoverlogicalcomponents.py
diff --git a/plugins/check_volume_status.py b/plugins/check_volume_status.py
index 072900a..70bed2f 100755
--- a/plugins/check_volume_status.py
+++ b/plugins/check_volume_status.py
@@ -94,6 +94,35 @@ def getVolumeSelfHealStatus(args):
return exitstatus, message
+def getVolumeGeoRepStatus(args):
+ try:
+ volume = glustercli.volumeGeoRepStatus(args.volume)
+ except glustercli.GlusterCmdFailedException as e:
+ out = ("Geo replication status could not be determined - %s"
+ % '.'.join(e.err))
+ return utils.PluginStatusCode.WARNING, out
+
+ if volume.get(args.volume) is None:
+ exitstatus = utils.PluginStatusCode.UNKNOWN
+ message = "UNKNOWN: Volume info not found"
+ else:
+ if (volume[args.volume]['status'] ==
+ glustercli.GeoRepStatus.PARTIAL_FAULTY):
+ exitstatus = utils.PluginStatusCode.WARNING
+ message = "Partially faulty - %s" % volume[args.volume]['detail']
+ elif volume[args.volume]['status'] == glustercli.GeoRepStatus.FAULTY:
+ exitstatus = utils.PluginStatusCode.CRITICAL
+ message = "Faulty - %s" % volume[args.volume]['detail']
+ elif (volume[args.volume]['status'] ==
+ glustercli.GeoRepStatus.NOT_STARTED):
+ exitstatus = utils.PluginStatusCode.WARNING
+ message = "Not Started"
+ else:
+ exitstatus = utils.PluginStatus.OK
+ message = "OK"
+ return exitstatus, message
+
+
def parse_input():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--volume", action="store",
@@ -103,7 +132,7 @@ def parse_input():
default="info",
dest="type",
help="Type of status to be shown. Possible values:",
- choices=["info", "quota", "self-heal"])
+ choices=["info", "quota", "self-heal", "geo-rep"])
args = parser.parse_args()
return args
@@ -116,5 +145,7 @@ if __name__ == '__main__':
exitstatus, message = getVolumeQuotaStatus(args)
if args.type == "self-heal":
exitstatus, message = getVolumeSelfHealStatus(args)
+ if args.type == "geo-rep":
+ exitstatus, message = getVolumeGeoRepStatus(args)
print message
exit(exitstatus)
diff --git a/tests/test_check_volume_status.py b/tests/test_check_volume_status.py
index 68c5a9b..ce7803e 100644
--- a/tests/test_check_volume_status.py
+++ b/tests/test_check_volume_status.py
@@ -65,6 +65,21 @@ class TestCheckVolumeStatus(TestCaseBase):
.getVolumeQuotaStatus(args))
assert exitStatusCode == utils.PluginStatusCode.WARNING
+ @mock.patch('glusternagios.glustercli.volumeGeoRepStatus')
+ def test_checkVolumeGeoRepStatus(self, mock_GeoRepStatus):
+ mock_GeoRepStatus.return_value = _getGeoRepStatus(glustercli
+ .GeoRepStatus.FAULTY)
+ args = ArgParseMock('test-cluster', 'test-vol', 'geo-rep')
+ exitStatusCode, exitStatusMsg = (check_volume_status
+ .getVolumeGeoRepStatus(args))
+ assert exitStatusCode == utils.PluginStatusCode.CRITICAL
+ mock_GeoRepStatus.return_value = _getGeoRepStatus(glustercli
+ .GeoRepStatus
+ .PARTIAL_FAULTY)
+ exitStatusCode, exitStatusMsg = (check_volume_status
+ .getVolumeGeoRepStatus(args))
+ assert exitStatusCode == utils.PluginStatusCode.WARNING
+
def _getVolume():
vol = {'test-vol': {'brickCount': 2,
@@ -100,3 +115,8 @@ def _expectedVolume():
def _getEmptyVolume():
return {}
+
+
+def _getGeoRepStatus(status):
+ return {'test-vol': {'status': status,
+ 'detail': "rhs3-2.novalocal - faulty;"}}