Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> correctly measure available memory in linux
aristosv
post Mar 27 2015, 02:15 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 8
Joined: 27-March 15
Member No.: 18,860



I'm currently using the command(s) 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?
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
aristosv
post Mar 27 2015, 05:57 AM
Post #2


Whats this Lie-nix Thing?
*

Group: Members
Posts: 8
Joined: 27-March 15
Member No.: 18,860



Thanks for your reply. Please note that the command I'm using has been put together using various bits and pieces found online. I don't completely comprehend how it works.
I understand that it greps the first "Mem" line and puts into variables the third and second value. Then divides the values and multiplies by 100.

How can I make a variable for the 898 number?
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 19th October 2017 - 06:10 AM