From 42f9dd823064741282b4f7f2575349014835902d Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Thu, 21 Apr 2016 13:09:21 -0500 Subject: [PATCH 1/2] ctdb-scripts: Avoid dividing by zero in memory calculation BUG: https://bugzilla.samba.org/show_bug.cgi?id=12362 Don't do a percentage calculation for either memtotal or swaptotal if they are zero. Signed-off-by: Jose A. Rivera Reviewed-by: Martin Schwenke (cherry picked from commit bf3f22315a281fb44a5cd9b075b7915138145d6e) --- ctdb/config/events.d/05.system | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctdb/config/events.d/05.system b/ctdb/config/events.d/05.system index 69fcec2..bfa8e7b 100755 --- a/ctdb/config/events.d/05.system +++ b/ctdb/config/events.d/05.system @@ -144,8 +144,8 @@ $1 == "SwapFree:" { swapfree = $2 } $1 == "SwapTotal:" { swaptotal = $2 } END { if (memavail != 0) { memfree = memavail ; } - print int((memtotal - memfree) / memtotal * 100), - int((swaptotal - swapfree) / swaptotal * 100) + if (memtotal != 0) { print int((memtotal - memfree) / memtotal * 100) ; } else { print 0 ; } + if (swaptotal != 0) { print int((swaptotal - swapfree) / swaptotal * 100) ; } else { print 0 ; } }') _mem_usage="$1" _swap_usage="$2" -- 2.7.4 From d77d61cfddc01338605b98948b1b923494336b1d Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 29 Jun 2016 17:47:12 +1000 Subject: [PATCH 2/2] ctdb-scripts: Fix incorrect variable reference BUG: https://bugzilla.samba.org/show_bug.cgi?id=12362 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit eabeecb45322747d7daeb2a79ac213f17eb049da) --- ctdb/config/events.d/05.system | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctdb/config/events.d/05.system b/ctdb/config/events.d/05.system index bfa8e7b..603f941 100755 --- a/ctdb/config/events.d/05.system +++ b/ctdb/config/events.d/05.system @@ -47,7 +47,7 @@ check_thresholds () fi fi - if validate_percentage "$_warn_threshold" "$_what" ; then + if validate_percentage "$_warn_threshold" "$_thing" ; then if [ "$_usage" -ge "$_warn_threshold" ] ; then if [ -r "$_cache" ] ; then read _prev <"$_cache" -- 2.7.4