Use total-used for memory usage indication instead of allocated and cached memory
This commit is contained in:
parent
f229a092d9
commit
d3094421ba
1 changed files with 4 additions and 2 deletions
|
@ -27,7 +27,7 @@ set -e;
|
||||||
HOSTNAME=$(hostname)
|
HOSTNAME=$(hostname)
|
||||||
SUBJECT="[memory $HOSTNAME] memory is low"
|
SUBJECT="[memory $HOSTNAME] memory is low"
|
||||||
MEMORY_USAGE_ALERT_MAIL_ADDRESS="";
|
MEMORY_USAGE_ALERT_MAIL_ADDRESS="";
|
||||||
MEMORY_USAGE_ALERT_THRESHOLD=128;
|
MEMORY_USAGE_ALERT_THRESHOLD=512;
|
||||||
|
|
||||||
# check for config file
|
# check for config file
|
||||||
source_config() {
|
source_config() {
|
||||||
|
@ -52,7 +52,9 @@ source_config() {
|
||||||
source_config "$1" "$HOME/.memory_usage_alert.conf"
|
source_config "$1" "$HOME/.memory_usage_alert.conf"
|
||||||
|
|
||||||
# DO NOT TOUCH BELOW
|
# 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
|
if [[ "$free" -le $MEMORY_USAGE_ALERT_THRESHOLD ]]; then
|
||||||
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head >/tmp/top_proccesses_consuming_memory.txt
|
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head >/tmp/top_proccesses_consuming_memory.txt
|
||||||
|
|
Loading…
Reference in a new issue