Operating System - HP-UX
1750505 Members
4622 Online
108777 Solutions
New Discussion юеВ

Command to find memory usage

 
SOLVED
Go to solution
Shivkumar
Super Advisor

Command to find memory usage

Hi,

I want to know the command to find out the total use of memory (RAM) without using the Glance or GlancePlus ?

Is there a command available for this ?

Thanks,
Shiv
8 REPLIES 8
Mustafa Gulercan
Respected Contributor
Solution

Re: Command to find memory usage

hi;

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.


# 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

regards;
mustafa
Steven E. Protter
Exalted Contributor

Re: Command to find memory usage

Shalom Shiv,

I respectfully submit swapinfo -tam as an alternative.

sar can be used to monitor various figures concerning memory use.

I also know I owe you an email. Personal situation is a bit hairy right now. Don't worry, I'll get to it.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Shivkumar
Super Advisor

Re: Command to find memory usage

I exexuted both commands and got the below output:-

# swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1024 0 1024 0% 0 - 1 /dev/vg00/lvol2
dev 1024 0 1024 0% 0 - 1 /dev/vg00/swap02
dev 512 0 512 0% 0 - 1 /dev/vg00/swap03
reserve - 130 -130
memory 1469 533 936 36%
total 4029 663 3366 16% - 0 -

# vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'
1130MB
#

Why there is too much difference between 2 command output ?

In the output of "swapinfo -tam" Is 4.029GB total available RAM or 1.469GB ?

Thanks,
Shiv
Ninad_1
Honored Contributor

Re: Command to find memory usage

Shiv,

swapinfo will show swap space usage.
Also sar will not show memory usage in HP [ In solaris sar -r shows memory usage :) ]
So you have only the following options
Glance - which you do not want to use [ I dont know why ]
vmstat - as suggested above or
UNIX95= ps -e -o "sz" | awk 'BEGIN {tot=0} {tot+=$1} END {print tot*4/1024,"MB"}'
I dont remember if there is any text appearing in the first line in output of
UNIX95= ps -e -o "sz"
Please check - if text appears in 1st line then modify above as
UNIX95= ps -e -o "sz" | tail +2 | awk 'BEGIN {tot=0} {tot+=$1} END {print tot*4/1024,"MB"}'

But again as there are shared memory segments which may be shared by multiple processes the memory calculated as above is approximate. You can compare with Glance once.

Regards,
Ninad
Arunvijai_4
Honored Contributor

Re: Command to find memory usage

Hi Shiv,

You should read this paper to understand how memory is used by HP-UX,

ftp://eh:spear9@hprc.external.hp.com/memory.htm


-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Chauhan Amit
Respected Contributor

Re: Command to find memory usage


# echo "freemem/D" | adb -k /stand/vmunix /dev/kmem

The output is the free memory in pages. Multiply the resulting number with 4 to get the free memory in Kbytes.

# echo "phys_mem_pages/D" | adb -k /stand/vmunix /dev/kmem

The output is the total memory in pages.Multiply the resulting number with 4 to get the free memory in Kbytes.

Used memory=Total memory-Free memory

grep -i physical /var/adm/syslog/syslog.log ---> To get physical RAM on system.


You can use this tool also:
/usr/contrib/Q4/bin/kmeminfo

-AMit
If you are not a part of solution , then you are a part of problem
Shivkumar
Super Advisor

Re: Command to find memory usage

Arun,

Thanks for the link provided to me. It is very useful.

Regards,
Shiv
Chauhan Amit
Respected Contributor

Re: Command to find memory usage

Check out this thread as well,

"Easy command line way to check memory usage"

http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0xa56442308663d611abdb0090277a778c%2C00.html&admit=-682735245+1149740463211+28353475
If you are not a part of solution , then you are a part of problem