1834020 Members
3095 Online
110063 Solutions
New Discussion

Calculating free memory.

 
SOLVED
Go to solution
Belinda Dermody
Super Advisor

Calculating free memory.

Is there any way using unix commands like vmstat to figure out how much free memory is available during periods of time. I have a K200 running 10.20 with 894K of memory and 4 CPU's. I have to report each week average memory usage and peak memory usage. I am pretty proficient with script writing, but I am not sure were to get the numbers to work with.
7 REPLIES 7
Kevin Wright
Honored Contributor

Re: Calculating free memory.

you could use vmstat, or glance if you have it to get this information.
I think Glance would be your best bet, with perfview you can store data in files forever if you want, then graph historic data. You could also do this yourself with sar, you'll probably find more info on this in this very forum.

James R. Ferguson
Acclaimed Contributor

Re: Calculating free memory.

Hi:

'vmstat' will report the active virtual pages and size of the free memory list. See the man pages for more details. You could periodically 'cron' command like:

# (date;vmstat -n 5 1) >> /tmp/myvmstats

This would take one snapshot everytime your cron task runs, appending it, with the current date to your log.

Obviously, I'd use 'awk' to dissect the output. This could (better) be done before piping the result into the log.

Regards!

...JRF...
Scott Robertson
Occasional Advisor
Solution

Re: Calculating free memory.

Howdy,

I was in a similar situation and finally decided to write a C program to report memory usage details. I've compiled and run this program with no problems on HP-UX versions 10.20 and 11.00. YMMV
*formally known as srobertson@bcbsga.com
Belinda Dermody
Super Advisor

Re: Calculating free memory.

Memory Stat total used avail %used
physical 192.0 183.0 9.0 95%
active virtual 63.4 20.5 42.9 32%
active real 19.3 10.2 9.1 53%
memory swap 135.0 122.6 12.4 91%
device swap 764.0 139.4 624.6 18%

I compiled the attach program and runs fine on my test/devel machine H50 192K memory. Now a silly question, I am a slow learner, I know what the 192 Physical memory is, but could you provide a brief laymen's terms with is the active/virtural and active/real memory with above numbers.

I want to thank the other submission. I have been using vmstat every 20 seconds for about 16 hours a day piping into one log for a week and then using awk to parse out and do a average and trying to find the peak. Just trying to find a easier and quicker way.
Scott Robertson
Occasional Advisor

Re: Calculating free memory.

Check this HP white paper on memory management, a few sections cover virutal memory.

http://www.docs.hp.com/hpux/onlinedocs/5965-4641/5965-4641.html
*formally known as srobertson@bcbsga.com
Deshpande Prashant
Honored Contributor

Re: Calculating free memory.

HI
If you have measureware agents running on your system, you can use extract command to capture required data (cpu/memory..) in text or xls format.
I use following command in script to extract global memory data for specified time period in 3 shifts for a day.

#extract -xp -G -b -e -s -r /var/opt/perf/rept.mem -f

Copy the /var/opt/perf/reptfile as rept.mem and unmask only memory related parameters. The format of output file (ASCII or WK1) is also specified in this file.

As long as measureware agents are running, you can use above command when ever you want to produce reports.

Thanks.
Prashant Deshpande.
Take it as it comes.
Glenn L. Stewart
Frequent Advisor

Re: Calculating free memory.

James,

I noted a small 'glitch' with that c program.

It should be noted that the device swap line also takes into account the 'reserved' quantity of device/filesystem swap (ie reserve line of swapinfo).

Example:
Memory Stat total used avail %used
device swap 1024.0 752.8 271.2 74%

Consists of:
swapinfo -atm

Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 512 27 485 5% 0 - 1 /dev/vg00/lvol2
dev 512 27 485 5% 0 - 1 /dev/vg00/swap2
reserve - 699 -699
memory 360 93 267 26%
total 1384 846 538 61% - 0 -

699 + 27 + 27 = 753 (as above with memdetail)

Glenn Stewart