diff options
author | Nishanth Thomas <nthomas@redhat.com> | 2014-06-03 11:31:23 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-06-04 03:36:16 -0700 |
commit | da2722d315a0866c52f425f176d3a1aa2b651a0e (patch) | |
tree | 2d3bcad780be4c5f83cad1fa431d21199e31d174 | |
parent | 88e20366bc84f7e6f68a21eee09c4135a7efa1eb (diff) |
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 <nthomas@redhat.com>
Reviewed-on: http://review.gluster.org/7959
Reviewed-by: Sahina Bose <sabose@redhat.com>
Tested-by: Sahina Bose <sabose@redhat.com>
-rwxr-xr-x | plugins/check_vol_utilization.py | 23 |
1 files changed, 19 insertions, 4 deletions
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) |