diff options
author | Martin Schwenke <martin@meltin.net> | 2019-03-29 11:19:55 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2019-05-07 05:45:34 +0000 |
commit | b80967f5dcc6b58db0c38ec3e5cf0cbe46dbeb4b (patch) | |
tree | 66c0171b773cb11e555ffcd1248ee112017a952b /ctdb/config | |
parent | 8108b3134c017c22d245fc5b2207a88d44ab0dd2 (diff) | |
download | samba-b80967f5dcc6b58db0c38ec3e5cf0cbe46dbeb4b.tar.gz |
ctdb-scripts: Drop script configuration variable CTDB_MONITOR_SWAP_USAGE
CTDB's system memory monitoring in 05.system.script monitors both main
memory and swap. The swap monitoring was originally based on
the (possibly incorrect, see below) idea that swap space stacks on top
of main memory, so that when a system starts filling swap space then
this is supposed to be a good sign that the system is running out of
memory. Additionally, performance on a Linux system tends to be
destroyed by the I/O associated with a lot of swapping to spinning
disks.
However, some platforms default to creating only 4GB of swap space
even when there is 128GB of main memory. With such a small swap to
main memory ratio, memory pressure can force swap to be nearly full
even when a significant amount of main memory is still available and
the system is performing well. This suggests that checking swap
utilisation might be less than useful in many circumstances.
So, remove the separate swap space checking and change the memory
check to cover the total of main memory and swap space.
Test function set_mem_usage() still takes an argument for each of main
memory and swap space utilisation. For simplicity, the same number is
now passed twice to make the intended results comprehensible. This
could be changed later.
A couple of tests are cleaned up to no longer use hard-coded
/proc/meminfo and ps output.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/config')
-rwxr-xr-x | ctdb/config/events/legacy/05.system.script | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/ctdb/config/events/legacy/05.system.script b/ctdb/config/events/legacy/05.system.script index e2ffeac715a..08e401a9e73 100755 --- a/ctdb/config/events/legacy/05.system.script +++ b/ctdb/config/events/legacy/05.system.script @@ -132,9 +132,6 @@ monitor_memory_usage () if [ -z "$CTDB_MONITOR_MEMORY_USAGE" ] ; then CTDB_MONITOR_MEMORY_USAGE=80 fi - if [ -z "$CTDB_MONITOR_SWAP_USAGE" ] ; then - CTDB_MONITOR_SWAP_USAGE=25 - fi _meminfo=$(get_proc "meminfo") # Intentional word splitting here @@ -149,21 +146,19 @@ $1 == "SwapFree:" { swapfree = $2 } $1 == "SwapTotal:" { swaptotal = $2 } END { if (memavail != 0) { memfree = memavail ; } - if (memtotal != 0) { print int((memtotal - memfree) / memtotal * 100) ; } else { print 0 ; } - if (swaptotal != 0) { print int((swaptotal - swapfree) / swaptotal * 100) ; } else { print 0 ; } + if (memtotal + swaptotal != 0) { + usedtotal = memtotal - memfree + swaptotal - swapfree + print int(usedtotal / (memtotal + swaptotal) * 100) + } else { + print 0 + } }') _mem_usage="$1" - _swap_usage="$2" check_thresholds "System memory" \ "$CTDB_MONITOR_MEMORY_USAGE" \ "$_mem_usage" \ dump_memory_info - - check_thresholds "System swap" \ - "$CTDB_MONITOR_SWAP_USAGE" \ - "$_swap_usage" \ - dump_memory_info } |