1846191 Members
4206 Online
110254 Solutions
New Discussion

memory usage commands

 
SOLVED
Go to solution
Jerry L. Sims
Frequent Advisor

memory usage commands

Does anyone know any GOOD tools (sar or vmstat,
etc.) to gather memory usage stats ? I need the
actual command syntax. Thanks........ :>)
7 REPLIES 7
Con O'Kelly
Honored Contributor
Solution

Re: memory usage commands

Hi Jerry

To Show Free memory on system:
# vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'

To Show Top Memory Processes:
# UNIX95= ps -el -o pid,comm,sz | grep -i -v pid | sort -nr -k 3,3 | head -15

This shows the top 15 processes for memory utilisation.

Cheers
Con

Sundar_7
Honored Contributor

Re: memory usage commands

Hi,

vmstat is the perfect tool for memory usage collection from the command line

# vmstat 1 1000 >> /tmp/vm.out

This will collect 1000 samples of vmstat output with an interval of 1 sec

# vmstat 1 >> /tmp/vmstat.out

The above command keeps collecting the vmstat output infinitely

Sundar.
Learn What to do ,How to do and more importantly When to do ?
Geoff Wild
Honored Contributor

Re: memory usage commands

Here's a script for you called memdetail - just compile it...

# memdetail
Memory Stat total used avail %used
physical 10080.0 9737.5 342.5 97%
active virtual 9586.4 4655.6 4930.8 49%
active real 7257.5 3446.8 3810.7 47%
memory swap 7697.1 1664.7 6032.5 22%
device swap 26528.0 9298.5 17229.5 35%

Rgds...Geoff


Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Kiyoshi Miyake
Frequent Advisor

Re: memory usage commands

Hi.

glancePlus is very useful.
but not free.

or:
vmstat | tail -1 | awk '{printf("%6.2f\n",$4*100/($4+$5))}'

but, vmstat show virtual + real memory.
(include disk swap)

Regards.
PVR
Valued Contributor

Re: memory usage commands

Get the trial version of glance. Glance will give you more accurate data than sar / top / vmstat .

Don't give up. Try till success...
Chauhan Amit
Respected Contributor

Re: memory usage commands

Hi Jerry,

I am attaching a wonderful tool to collect the memory information. Given below is the procedure to install and sample output.

Procdure to use:
#chmod 777 kmeminfo.bin
#./kmeminfo.bin
#kmeminfo

Sample Output:
--------------------------
Physical memory usage summary (in page/byte/percent):

Physmem = 1572864 6.0g 100% Physical memory
Freemem = 293069 1.1g 19% Free physical memory
Used = 1279795 4.9g 81% Used physical memory
System = 396296 1.5g 25% By kernel:
text = 1977 7.7m 0% text
data = 282 1.1m 0% data
bss = 1596 6.2m 0% bss
Static = 81101 316.8m 5% for text/static data
Dynamic = 154798 604.7m 10% for dynamic data
Bufcache = 157286 614.4m 10% for buffer cache
Eqmem = 39 156.0k 0% for equiv. mapped memory
SCmem = 3072 12.0m 0% for critical memory
User = 887688 3.4g 56% By user processes:
Uarea = 6104 23.8m 0% for thread uareas
Disowned = 8 32.0k 0% Disowned pages

Total Memory : 6GB

Free Memory : 1.1g

Cheers,
Amit
If you are not a part of solution , then you are a part of problem
Rory R Hammond
Trusted Contributor

Re: memory usage commands

As to a previous suggestion....
I NEVER recommend chmod 777 on executable. To easy for a trojan horse. Especially a item that you know that root is going to use.

For 11X OS
echo 'phys_mem_pages/D'|
adb /stand/vmunix /dev/kmem|
grep pages | tail -1 |
awk '{print $2}'
For 10.2 OS
echo 'physmem/D'|
adb /stand/vmunix /dev/kmem |
tail -1 |
awk '{print $2}'

swapinfo is aslo helpful to see if your are swaping.

There are a 100 ways to do things and 97 of them are right