Use total-used for memory usage indication instead of allocated and cached memory

This commit is contained in:
Alexander Schäferdiek 2020-01-21 08:09:10 +01:00
parent f229a092d9
commit d3094421ba

View file

@ -27,7 +27,7 @@ set -e;
HOSTNAME=$(hostname)
SUBJECT="[memory $HOSTNAME] memory is low"
MEMORY_USAGE_ALERT_MAIL_ADDRESS="";
MEMORY_USAGE_ALERT_THRESHOLD=128;
MEMORY_USAGE_ALERT_THRESHOLD=512;
# check for config file
source_config() {
@ -52,7 +52,9 @@ source_config() {
source_config "$1" "$HOME/.memory_usage_alert.conf"
# DO NOT TOUCH BELOW
free=$(free -mt | grep Total | awk '{print $4}')
total=$(free -mt | grep Total | awk '{print $2}')
used=$(free -mt | grep Total | awk '{print $3}')
free=$(($total-$used))
if [[ "$free" -le $MEMORY_USAGE_ALERT_THRESHOLD ]]; then
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head >/tmp/top_proccesses_consuming_memory.txt