1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/ctdb/tests/eventscripts/05.system.monitor.018.sh
Martin Schwenke b80967f5dc 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>
2019-05-07 05:45:34 +00:00

83 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "Memory check (custom, both), check throttling of warnings"
setup
setup_script_options <<EOF
CTDB_MONITOR_MEMORY_USAGE="70:80"
EOF
# Below threshold, nothing logged
set_mem_usage 67 67
ok_null
simple_test
set_mem_usage 71 71
ok "WARNING: System memory utilization 71% >= threshold 70%"
simple_test
# 2nd time at same level, nothing logged
set_mem_usage 71 71
ok_null
simple_test
set_mem_usage 73 73
ok "WARNING: System memory utilization 73% >= threshold 70%"
simple_test
# 2nd time at same level, nothing logged
set_mem_usage 73 73
ok_null
simple_test
set_mem_usage 79 79
ok "WARNING: System memory utilization 79% >= threshold 70%"
simple_test
set_mem_usage 80 80
required_result 1 <<EOF
ERROR: System memory utilization 80% >= threshold 80%
$FAKE_PROC_MEMINFO
$(ps foobar)
EOF
simple_test
# Fall back into warning at same level as last warning... should log
set_mem_usage 79 79
ok "WARNING: System memory utilization 79% >= threshold 70%"
simple_test
# Below threshold, notice
set_mem_usage 69 69
ok <<EOF
NOTICE: System memory utilization 69% < threshold 70%
EOF
simple_test
# Further reduction, nothing logged
set_mem_usage 68 68
ok_null
simple_test
# Back up into warning at same level as last warning... should log
set_mem_usage 79 79
ok "WARNING: System memory utilization 79% >= threshold 70%"
simple_test
# Back up above critical threshold... unhealthy
set_mem_usage 81 81
required_result 1 <<EOF
ERROR: System memory utilization 81% >= threshold 80%
$FAKE_PROC_MEMINFO
$(ps foobar)
EOF
simple_test
# Straight back down to a good level... notice
set_mem_usage 65 65
ok "NOTICE: System memory utilization 65% < threshold 70%"
simple_test