diff options
author | Sahina Bose <sabose@redhat.com> | 2014-04-21 16:32:37 +0530 |
---|---|---|
committer | Bala.FA <barumuga@redhat.com> | 2014-04-29 10:14:33 +0530 |
commit | ffbcb9f68641db3cc815275b48861b817d43bbd4 (patch) | |
tree | e10438a445ea9bc6f25294482c8afe1f813c7daa /plugins | |
parent | 3cce71403b424fb9d37e3a2f381426bb43a06b24 (diff) |
plugins: Added self heal status option
Added self-heal status option to the
check_volume_status plugin
Change-Id: Ia48f7baa3b6e4f0091be2116ab058ab48f1e5a29
Signed-off-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/check_volume_status.py | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/plugins/check_volume_status.py b/plugins/check_volume_status.py index 7c72ef9..5f0e067 100755 --- a/plugins/check_volume_status.py +++ b/plugins/check_volume_status.py @@ -54,7 +54,8 @@ def getVolumeQuotaStatus(args): try: status = glustercli.volumeQuotaStatus(args.volume) except glustercli.GlusterCmdFailedException as e: - out = ("QUOTA: Quota status could not be determined %s" % e.message) + out = ("QUOTA: Quota status could not be determined %s" + % '.'.join(e.err)) return utils.PluginStatusCode.UNKNOWN, out if status == glustercli.VolumeQuotaStatus.EXCEEDED: @@ -65,6 +66,33 @@ def getVolumeQuotaStatus(args): return utils.PluginStatusCode.OK, "QUOTA: OK" +def getVolumeSelfHealStatus(args): + try: + volume = glustercli.volumeHealSplitBrainStatus(args.volume) + except glustercli.GlusterCmdFailedException as e: + out = ("Self heal 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 self heal info not found" + else: + if (volume[args.volume]['status'] == glustercli. + VolumeSplitBrainStatus.NOTAPPLICABLE): + exitstatus = utils.PluginStatusCode.OK + message = "Volume is not of replicate type" + elif (volume[args.volume]['status'] == glustercli. + VolumeSplitBrainStatus.OK): + exitstatus = utils.PluginStatusCode.OK + message = "No unsynced entries present" + elif (volume[args.volume]['status'] == glustercli. + VolumeSplitBrainStatus.SPLITBRAIN): + exitstatus = utils.PluginStatusCode.CRITICAL + message = ("Unsynced entries present %s" + % (volume[args.volume]['unsyncedentries'])) + return exitstatus, message + def parse_input(): parser = argparse.ArgumentParser() parser.add_argument("-v", "--volume", action="store", @@ -74,7 +102,7 @@ def parse_input(): default="info", dest="type", help="Type of status to be shown. Possible values:", - choices=["info", "quota"]) + choices=["info", "quota", "self-heal"]) args = parser.parse_args() return args @@ -85,5 +113,7 @@ if __name__ == '__main__': exitstatus, message = getVolumeStatus(args) if args.type == "quota": exitstatus, message = getVolumeQuotaStatus(args) + if args.type == "self-heal": + exitstatus, message = getVolumeSelfHealStatus(args) print message exit(exitstatus) |