From 481d99ef5f541b4e1eb30d4f630c890609a1c05e Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Mon, 2 Mar 2015 14:28:00 +0530 Subject: nagios-common: Split brain status function added Modified the existing function to return the "volume heal info split-brain" output to be used by nagios plugins. The function that uses "volume heal info" command has been renamed Change-Id: I5a05930ae76be04535c74cffd5f535bfb6a6d97a Bug-Url: https://bugzilla.redhat.com/1081900 Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/9782 Reviewed-by: darshan n --- glusternagios/glustercli.py | 31 +++++++++++++++++++++++++++---- tests/test_glustercli.py | 4 ++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/glusternagios/glustercli.py b/glusternagios/glustercli.py index 4ec8194..809dced 100755 --- a/glusternagios/glustercli.py +++ b/glusternagios/glustercli.py @@ -493,11 +493,11 @@ def _parseVolumeQuotaStatus(out, isDisabled=False): return status_detail -def _parseVolumeSelfHealSplitBrainInfo(out): +def _parseVolumeSelfHealInfo(out): value = {} splitbrainentries = 0 for line in out: - if line.startswith('Number of entries:'): + if line.startswith('Number of entries'): entries = int(line.split(':')[1]) if entries > 0: splitbrainentries += entries @@ -613,7 +613,7 @@ def volumeGeoRepStatus(volumeName, remoteServer=None): raise GlusterCmdFailedException(rc=rc, out=out, err=err) -def volumeHealSplitBrainStatus(volumeName, remoteServer=None): +def volumeHealStatus(volumeName, remoteServer=None): """ Arguments: * VolumeName @@ -622,6 +622,29 @@ def volumeHealSplitBrainStatus(volumeName, remoteServer=None): 'unsyncedentries': ENTRYCOUNT}} """ command = _getGlusterVolCmd() + ["heal", volumeName, "info"] + return _volumeHealCommandOutput(volumeName, command, remoteServer) + + +def volumeHealSplitBrainStatus(volumeName, remoteServer=None): + """ + Arguments: + * VolumeName + Returns: + {VOLUMENAME: {'status': SELFHEALSTATUS, + 'unsyncedentries': ENTRYCOUNT}} + """ + command = _getGlusterVolCmd() + ["heal", volumeName, "info", "split-brain"] + return _volumeHealCommandOutput(volumeName, command, remoteServer) + + +def _volumeHealCommandOutput(volumeName, command, remoteServer=None): + """ + Arguments: + * VolumeName + Returns: + {VOLUMENAME: {'status': SELFHEALSTATUS, + 'unsyncedentries': ENTRYCOUNT}} + """ if remoteServer: command += ['--remote-host=%s' % remoteServer] @@ -629,7 +652,7 @@ def volumeHealSplitBrainStatus(volumeName, remoteServer=None): volume = {} value = {} if rc == 0: - value = _parseVolumeSelfHealSplitBrainInfo(out) + value = _parseVolumeSelfHealInfo(out) volume[volumeName] = value return volume else: diff --git a/tests/test_glustercli.py b/tests/test_glustercli.py index 67260a8..bca1502 100644 --- a/tests/test_glustercli.py +++ b/tests/test_glustercli.py @@ -1255,10 +1255,10 @@ class GlusterCliTests(TestCaseBase): "", "Brick node2:/bricks/b3", "Status: Brick is Not connected", - "Number of entries: 0" + "Number of entries in split-brain: 0" "", "Brick node1:/bricks/b3", - "Number of entries: 10", + "Number of entries in split-brain: 10", "/dir.7/file.5", "/dir.8/file.3", "/dir.9/file.5", -- cgit