diff options
author | Sahina Bose <sabose@redhat.com> | 2015-03-02 14:28:00 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2015-03-25 04:56:31 -0700 |
commit | 481d99ef5f541b4e1eb30d4f630c890609a1c05e (patch) | |
tree | 246214f266926b76230db612671f94a35737ef4f /glusternagios/glustercli.py | |
parent | 2132a0f6927275e76c5e55069acc3e8314567475 (diff) |
nagios-common: Split brain status function added
Modified the existing function to return the
"volume heal <vol-name> info split-brain" output
to be used by nagios plugins.
The function that uses "volume heal <vol-name> info"
command has been renamed
Change-Id: I5a05930ae76be04535c74cffd5f535bfb6a6d97a
Bug-Url: https://bugzilla.redhat.com/1081900
Signed-off-by: Sahina Bose <sabose@redhat.com>
Reviewed-on: http://review.gluster.org/9782
Reviewed-by: darshan n <dnarayan@redhat.com>
Diffstat (limited to 'glusternagios/glustercli.py')
-rwxr-xr-x | glusternagios/glustercli.py | 31 |
1 files changed, 27 insertions, 4 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: |