diff options
author | ndarshan <dnarayan@redhat.com> | 2014-04-21 12:19:06 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-05-08 01:49:08 -0700 |
commit | e96918e80ce059ed3dbd2099db00eee8c120809f (patch) | |
tree | d74babe69a768969e9ad15d7171bf39e0500a0d2 /plugins/swap.py | |
parent | b87f9527515f27f145cc6b5cff1e68bab5cf2b21 (diff) |
rhs-addons:Fix: Modified swap and memory plugin to show in GB.
Modified swap and memory plugin to show message and performance
data in GB instead of kB.
https://bugzilla.redhat.com/show_bug.cgi?id=1080004
Signed-off-by: ndarshan <dnarayan@redhat.com>
Change-Id: I06cfd4cd8e19ac8bc21c50ee0f37f15b4ae8cc2e
Reviewed-on: http://review.gluster.org/7640
Reviewed-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'plugins/swap.py')
-rwxr-xr-x | plugins/swap.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/plugins/swap.py b/plugins/swap.py index 5e44f6e..002d287 100755 --- a/plugins/swap.py +++ b/plugins/swap.py @@ -44,7 +44,9 @@ def showSwapStat(warning, critical, s): pl_op['exit_status'] = utils.PluginStatusCode.UNKNOWN return pl_op try: - totalSwap = int(s['memory']['swpfree']) + int(s['memory']['swpused']) + totalSwap = utils.convertSize((int(s['memory']['swpfree']) + + int(s['memory']['swpused'])), + "KB", "GB") except (KeyError, ValueError, TypeError) as e: pl_op["message"] = "key: %s not found" % str(e) pl_op["exit_status"] = utils.PluginStatusCode.UNKNOWN @@ -52,22 +54,26 @@ def showSwapStat(warning, critical, s): crit_value = (totalSwap * critical) / 100 war_value = (totalSwap * warning) / 100 - if int(s['memory']['swpused']) >= crit_value: + if utils.convertSize(int(s['memory']['swpused']), + "KB", "GB") >= crit_value: pl_op["message"] = utils.PluginStatus.CRITICAL pl_op['exit_status'] = utils.PluginStatusCode.CRITICAL - elif int(s['memory']['swpused']) >= war_value: + elif utils.convertSize(int(s['memory']['swpused']), + "KB", "GB") >= war_value: pl_op["message"] = utils.PluginStatus.WARNING pl_op['exit_status'] = utils.PluginStatusCode.WARNING else: pl_op["message"] = utils.PluginStatus.OK pl_op['exit_status'] = utils.PluginStatusCode.OK try: - pl_op["message"] += ("- %.2f%% used(%skB out of %skB)|Used=%skB;%s;" - "%s;0;%s" % ( + pl_op["message"] += ("- %.2f%% used(%.2fGB out of %.2fGB)|Used=%.2fGB;" + "%.2f;%.2f;0;%.2f" % ( float(s['memory']['swpused-percent']), - s['memory']['swpused'], + utils.convertSize(int(s['memory']['swpused']), + "KB", "GB"), totalSwap, - s['memory']['swpused'], + utils.convertSize(int(s['memory']['swpused']), + "KB", "GB"), war_value, crit_value, totalSwap)) |