From 81cc690fbe74f15e73c30079ea4bff1c37fefa3f Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Thu, 27 Mar 2014 15:31:31 +0530 Subject: plugins: Fixed issue with cluster util plugin Fixed an issue with cluster utilization plugin Also refactored code Change-Id: I7a86d9311ddf302dab93cb4aa8e5f57a5f868ec0 Signed-off-by: Sahina Bose Reviewed-on: https://code.engineering.redhat.com/gerrit/21996 Reviewed-by: Shubhendu Tripathi --- plugins/check_cluster_vol_usage.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/check_cluster_vol_usage.py b/plugins/check_cluster_vol_usage.py index 59c2335..1a77d93 100755 --- a/plugins/check_cluster_vol_usage.py +++ b/plugins/check_cluster_vol_usage.py @@ -30,7 +30,8 @@ import sys import re from argparse import ArgumentParser -from plugins import livestatus +import livestatus +from glusternagios import utils def checkVolumePerfData(clusterName): @@ -82,23 +83,25 @@ if __name__ == "__main__": args = parser.parse_args() # Check the various performance statuses for the host used, avail = checkVolumePerfData(args.hostgroup) - statusstr = "OK" - exitstatus = 0 + statusstr = utils.PluginStatus.OK + exitstatus = utils.PluginStatusCode.OK if used == 0 and avail == 0: - statusstr = "UNKNOWN" - exitstatus = 3 + statusstr = utils.PluginStatus.UNKNOWN + exitstatus = utils.PluginStatusCode.UNKNOWN + print ("%s - No volumes found" % statusstr) else: warn = int((args.warn * avail) / 100.0) crit = int((args.crit * avail) / 100.0) usedpercent = int((used / avail) * 100.0) if (usedpercent >= args.warn): - statusstr = "WARNING" - exitstatus = 1 + statusstr = utils.PluginStatus.WARNING + exitstatus = utils.PluginStatusCode.WARNING if (usedpercent >= args.crit): - statusstr = "CRITICAL" - exitstatus = 2 + statusstr = utils.PluginStatus.CRITICAL + exitstatus = utils.PluginStatusCode.CRITICAL + availGB = utils.convertSize(avail, "KB", "GB") + print ("%s - used %s%% of available %s GB|used=%s;%s;%s;0;%s;" + % (statusstr, usedpercent, + availGB, usedpercent, args.warn, args.crit, 100)) - print ("%s - used %s%% of available %s|used=%s;%s;%s;0;%s;" - % (statusstr, usedpercent, - avail, usedpercent, args.warn, args.crit, 100)) sys.exit(exitstatus) -- cgit