I'm currently using the command below, to output the memory usage of a debian system in bash scripts.
Code:
memusage=$(memusage=$(/usr/bin/free | grep Mem | awk '{print $3/$2 * 100.0 "%"}' | cut -d "%" -f1);echo "$(printf "%0.0f\n" $memusage)") && echo Memory Usage is $memusage
Being new to Linux though, I just found out that Linux takes up a lof of memory and puts it in cached.
Code:
root@Client1:~# free -m
total used free shared buffers cached
Mem: 927 799 128 0 15 754
-/+ buffers/cache: 28 898
Swap: 99 0 99
So the first command will actually output that the memory usage is 87%, when in reality is not. Its actually thinking that the memory usage is high because its also counting the cached memory, as used memory.
How can I modify the first command not to consider cached memory, as used memory?
Thanks