diff --git a/usr/local/bin/memory_usage_alert b/usr/local/bin/memory_usage_alert index 40c0837..6ee3be0 100755 --- a/usr/local/bin/memory_usage_alert +++ b/usr/local/bin/memory_usage_alert @@ -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