From da2722d315a0866c52f425f176d3a1aa2b651a0e Mon Sep 17 00:00:00 2001 From: Nishanth Thomas Date: Tue, 3 Jun 2014 11:31:23 +0530 Subject: gluster-nagios-addons:Added more checks to provide details in plugin output check_proc_status.py - when a volume is down, brick status was always showing up unless initiate a pre-scheduled check. Removed an unnecessary check to fix this issue check_vol_utilization.py - modified the volume utilization plugin so that the plugin ouput is meaninful when a volume is nonexistent or stopped Change-Id: I04b8d8fc5ae19b2ae9f4969a7239a9449f2acd0f Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1083451 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1090854 Signed-off-by: Nishanth Thomas Reviewed-on: http://review.gluster.org/7959 Reviewed-by: Sahina Bose Tested-by: Sahina Bose --- plugins/check_vol_utilization.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/check_vol_utilization.py b/plugins/check_vol_utilization.py index 151a724..ab58e58 100755 --- a/plugins/check_vol_utilization.py +++ b/plugins/check_vol_utilization.py @@ -21,6 +21,7 @@ import sys import argparse import capacity from glusternagios import utils +from glusternagios import glustercli def showVolumeUtilization(vname, warnLevel, critLevel): @@ -46,10 +47,6 @@ def showVolumeUtilization(vname, warnLevel, critLevel): #used size in KB used_size = total_size - ((buf['f_bsize'] * buf['f_bfree']) * 0.000976563) vol_utilization = (used_size / total_size) * 100 -# print int(total_size) -# print int(free_size) -# print int(used_size) -# print vol_utilization perfLines = [] perfLines.append(("utilization=%s%%;%s;%s total=%s " "used=%s free=%s" % (str(int(vol_utilization)), @@ -76,6 +73,22 @@ def showVolumeUtilization(vname, warnLevel, critLevel): sys.exit(utils.PluginStatusCode.OK) +def check_volume_status(volume): + try: + volumes = glustercli.volumeInfo(volume) + if volumes.get(volume) is None: + sys.stdout.write("CRITICAL: Volume not found\n") + sys.exit(utils.PluginStatusCode.CRITICAL) + elif volumes[volume]["volumeStatus"] == \ + glustercli.VolumeStatus.OFFLINE: + sys.stdout.write("CRITICAL: Volume is stopped\n") + sys.exit(utils.PluginStatusCode.CRITICAL) + except glustercli.GlusterCmdFailedException: + sys.stdout.write("UNKNOWN: Failed to get the " + "Volume Utilization Data\n") + sys.exit(utils.PluginStatusCode.UNKNOWN) + + def parse_input(): parser = argparse.ArgumentParser( @@ -103,4 +116,6 @@ def parse_input(): if __name__ == '__main__': args = parse_input() + #check the volume status before getting the volume utilization + check_volume_status(args.volume) showVolumeUtilization(args.volume, args.warning, args.critical) -- cgit