Hi,
The following script will check for top 20 processes which uses maximum memory resource in the server and will store it in “overusage” file only if the free memory goes below 700MB. Set cron to execute this script whenever needed.
#!/bin/bash
#High RAM usage checker
r=`free -m |awk 'NR==3' |awk '{ print$4 }'`
if [ $r -lt 700 ];
then
ps -e -orss=,args= | sort -b -k1,1n |tail -n 20 >> overusage
exit
fi
Hello,
This script will check the free memory without taking into account the cached and buffered memories
For example
free -m
total used free shared buffers cached
Mem: 3894 3719 174 0 121 1965
-/+ buffers/cache: 1632 2262
Swap: 8191 0 8191
This machine has around 2GB of free memory, even if the free column show just 174.
http://linux-mm.org/
You are right, I would possibly write another script to take cache and buffered RAM into account for calculation.
Yes, you are right.. You want me to sum up buffer along with RAM as well?