From 2835f93524feef024d75df8342398d94376778cd Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Wed, 30 Sep 2015 19:01:06 +0530 Subject: nagios-plugins: Heal info monitoring Added nrpe plugin to monitor heal info Plugin will change to Critical state when heal is in progress renamed reference to VolumeSplitBrainStatus as generic VolumeHealInfoStatus Change-Id: I6fdc893a80ec1c33881d8bc838a33111d2da5d9b Bug-Url: https://bugzilla.redhat.com/1267586 Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/12261 Reviewed-by: Ramesh N --- plugins/check_volume_status.py | 46 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/check_volume_status.py b/plugins/check_volume_status.py index 444c7d3..ee7cef0 100755 --- a/plugins/check_volume_status.py +++ b/plugins/check_volume_status.py @@ -99,21 +99,56 @@ def getVolumeSelfHealSplitBrainStatus(args): message = "UNKNOWN: Volume self heal split-brain info not found" else: if (volume[args.volume]['status'] == glustercli. - VolumeSplitBrainStatus.NOTAPPLICABLE): + VolumeHealInfoStatus.NOTAPPLICABLE): exitstatus = utils.PluginStatusCode.OK message = "Volume is not of replicate type" elif (volume[args.volume]['status'] == glustercli. - VolumeSplitBrainStatus.OK): + VolumeHealInfoStatus.OK): exitstatus = utils.PluginStatusCode.OK message = "No split brain state entries found." elif (volume[args.volume]['status'] == glustercli. - VolumeSplitBrainStatus.SPLITBRAIN): + VolumeHealInfoStatus.ENTRIESFOUND): exitstatus = utils.PluginStatusCode.CRITICAL message = ("%s entries in split-brain state found." % (volume[args.volume]['unsyncedentries'])) return exitstatus, message +def getVolumeSelfHealProgressStatus(args): + try: + volume = glustercli.volumeHealStatus(args.volume) + except glustercli.GlusterLockedException as e: + out = ("UNKNOWN: Glusterd cannot be queried. %s" % '.'.join(e.err)) + return utils.PluginStatusCode.UNKNOWN, out + except glustercli.GlusterCmdFailedException as e: + out = ("Volume heal information 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. + VolumeHealInfoStatus.NOTAPPLICABLE): + exitstatus = utils.PluginStatusCode.OK + message = "Volume is not of replicate type" + elif volume[args.volume]['undergoingheal'] > 0: + exitstatus = utils.PluginStatusCode.CRITICAL + message = "Volume self-heal in progress." + elif volume[args.volume]['unsyncedentries'] > 0: + exitstatus = utils.PluginStatusCode.WARNING + message = "Unsynced entries found." + elif (volume[args.volume]['unsyncedentries'] == 0): + exitstatus = utils.PluginStatusCode.OK + message = "No unsynced entries found." + + message += ("| undergoing=%s unsyncedentries=%s" % + (volume[args.volume]['undergoingheal'], + volume[args.volume]['unsyncedentries'])) + return exitstatus, message + + def getVolumeGeoRepStatus(args): try: volume = glustercli.volumeGeoRepStatus(args.volume) @@ -161,7 +196,8 @@ def parse_input(): default="info", dest="type", help="Type of status to be shown. Possible values:", - choices=["info", "quota", "self-heal", "geo-rep"]) + choices=["info", "quota", "self-heal", + "geo-rep", "heal-info"]) args = parser.parse_args() return args @@ -176,5 +212,7 @@ if __name__ == '__main__': exitstatus, message = getVolumeSelfHealSplitBrainStatus(args) if args.type == "geo-rep": exitstatus, message = getVolumeGeoRepStatus(args) + if args.type == "heal-info": + exitstatus, message = getVolumeSelfHealProgressStatus(args) print message exit(exitstatus) -- cgit