1753905 Members
9733 Online
108810 Solutions
New Discussion юеВ

Re: Virtual Memory

 
SOLVED
Go to solution
EnmaAi
Occasional Advisor

Virtual Memory

Hi!
I'm want to do a script to monitorize virtual memory of an sprecific process.

Any commands/ideas will be great!!!

Can I use "memstat" in HP_UX or is it just for solaris?
9 REPLIES 9
Wouter Jagers
Honored Contributor

Re: Virtual Memory

Hiya,

Depending on your exact needs, maybe the output of ps could already be helpful. When using '-l' (that's a lowercase L) you will get a SZ-field, described in the manpage:

sz: The size in physical pages of the core image of the process, including text, data, and stack space. Physical page size is defined by
_SC_PAGE_SIZE in the header file (see sysconf(2) and unistd(5)).

I don't know if that's good enough for your reporting needs, but it could be an 'easy way'.. note that memory on unix machines is a complicated area :)

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
Hasan  Atasoy
Honored Contributor

Re: Virtual Memory

hi enmai;

memstat for solaris only. but you can use

UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm


Hasan.
EnmaAi
Occasional Advisor

Re: Virtual Memory

Hi!

I'm afraid ps is not very useful cause i need virtual memory, not physical.

Hasan: I don't understand your command...

^_^

I've also read glance is useful.

Any other ideas will be of great help ;)
James R. Ferguson
Acclaimed Contributor

Re: Virtual Memory

Hi:

> I'm afraid ps is not very useful cause i need virtual memory, not physical

Huh? Do you care where the process's memory really exists --- in physical RAM; versus paged out in swap? What matters is the overall memory footprint for a process.

Regards!

...JRF...
Hasan  Atasoy
Honored Contributor

Re: Virtual Memory

hi ;
if you want to monitor process=1200 then


while true
do
UNIX95= ps -eo "pid vsz=Kbytes" | grep 1200 | awk '{print $2}' >> logfile
done


Hasan  Atasoy
Honored Contributor

Re: Virtual Memory

sory a correction . for 1 minutes interval


while true
do
UNIX95= ps -eo "pid vsz=Kbytes" | grep 1200 | awk '{print $2}' >> logfile
sleep 60
done
Wouter Jagers
Honored Contributor
Solution

Re: Virtual Memory

Glance indeed has nice functionality for calculating the RSS/VSS of a process.

You can tell glance to log this to a file, but you have to create a file with some adviser commands.

Quick and dirty example file (let's name the file 'syntaxfile'):
--CUT HERE--
process loop {
if proc_proc_name == "top" then
print gbl_stattime,proc_proc_id," ",proc_proc_name,proc_mem_virt
}
--CUT HERE--

This example, as you can probably figure out, will tell glance to select processes named "top" and print their PID, name and VSS (virtual set size, which you wanted to know), prepended by the time.

In order to run glance with this information, you could run:

# glance -adviser_only -syntax syntaxfile > outputfile

You could run this in the background if you want, and specify the interval (-j), number of iterations (-iterations) or other common glance options.

When I run the above while a top is running on the machine, my output file looks like this:

17:22:29 4073 top 5.2mb
17:22:34 4073 top 5.2mb
17:22:39 4073 top 5.2mb
...

More info in 'man glance' and more examples in /opt/perf/examples/adviser.

Hope that helps,
Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
EnmaAi
Occasional Advisor

Re: Virtual Memory

Thanks to all for your help. I'm experimenting with glance which I think is the best solution ^_^
EnmaAi
Occasional Advisor

Re: Virtual Memory

Solved with glance