Operating System - HP-UX
1755407 Members
4754 Online
108832 Solutions
New Discussion юеВ

getting number of processes and memory consumption

 
SOLVED
Go to solution
Christian Marquardt_1
Regular Advisor

getting number of processes and memory consumption

Hello,
I've the requirement to create a job (script) which hourly get infos about the number of oracle-prozesses and the memory consumption of this processes.
Has anyone an idea how to do this?
Machine Setup: rp4440, HP/UX 11.11 64-Bit and iAS 10g (9.0.4).

kind regards
Christian
9 REPLIES 9
Slawomir Gora
Honored Contributor

Re: getting number of processes and memory consumption

Hi,

number of oracle processes:

ps -ef | grep -c oracle

Christian Marquardt_1
Regular Advisor

Re: getting number of processes and memory consumption

Hello Slawomir,
thanks for the answer. I know the ps -ef command. That is the easy part of the job. The difficult part is to get the memory consumption of these processes at a determined point of time and write the number and the memory consumption to a file. So I can create a history about the number of processes and how much memory these processses allocate.

regards
Christian
Fred Ruffet
Honored Contributor
Solution

Re: getting number of processes and memory consumption

There may be two ways : One dealing with ps, other one with oracle.

If you use ps, you will go into problems with shared memory segments appearing for each process as his memory. You will have to sum...

If you simply connect to Oracle and do two selects, you'll have all :
sqlplus "/ as sysdba" << EOF
select count(*) as "sessions" from v$session;
-- get sga size
select value as "sga"
from v$parameter
where name='sga_max_size';
-- get actual pga size
select value as "pga"
from v$pgastat
where name='total PGA allocated';
exit
EOF

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Victor BERRIDGE
Honored Contributor

Re: getting number of processes and memory consumption

Hi Christian
I wrote a script ot totalize a user's total memory consumption:

Give the users name for argument ($1)

#!/usr/bin/ksh
USER=$1
let USERMEM=0;
let NEWUSERMEM=0;
UNIX95= ps -eo "pid ruser vsz=Kbytes" |grep $1| while read PID LINE USERMEM
do
echo $LINE" PID "$PID " Kbytes = "$USERMEM
let NEWUSERMEM=$USERMEM+$NEWUSERMEM
done

echo "Total $USER memory usage = " $NEWUSERMEM " Kbytes"
#

All the best
Victor
Christian Marquardt_1
Regular Advisor

Re: getting number of processes and memory consumption

Hello Fred,
that's a good idea. My problem: The DB is on another machine. If I run the following statement in the DB:

select * from v$session where machine like 'iukweb%' and program like 'f90run%'

... where iukweb% are the two webservers und f90run% are the forms processes (would count forms-processes). Can I use this and count the memory values in v$process to get the summary of memory allocation of this processes in the webserver-machine?

regards
Christian
Fred Ruffet
Honored Contributor

Re: getting number of processes and memory consumption

Victor,

This script won't work, as long as it doesn't deal with shared memory. In Christian's case, you should substract shared memory part from each vsz and then add it once.

Christian,

Adding the two clauses will effectively restrict to the sessions you want.
Still the point of memory consumption : Script I gave shows you total memory comsumption for Oracle instance. As long as SGA and PGA are pools common to all the processes, you cannot isolate some process to determine how much memory it uses...

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Christian Marquardt_1
Regular Advisor

Re: getting number of processes and memory consumption

Hello Fred,
I think that I can't isolate SGA and PGA memory for every process too.
If I look in my unix system (by TOP) I find some processes like the following:

ias904 7676 11339 0 10:59:45 ? 0:47 /oracle/product/web/9.0.4/bin/f90webm server webfile=HTTP-0,0,0

I will count the number and the memory consumption of this processes. I can't use Victor's script because there are other processes started by user "ias904".
There's no database installed on the webserver-machine. Maybe there's a unix tool to show the memory consumption like GLANCE?!?!?

regards
Christian
Bill Hassell
Honored Contributor

Re: getting number of processes and memory consumption

ps is a lot more powerful than most sysadmins realize. First, always avoid the use of grep and ps--it will always give you misleading results because grep does understand the concept of fields, it just just matches anything on the line. To find all processes that are being run by a specific user, use the -u option, several users can be scanned: ps -u user1,user2,oracle

To find specific process names, always use the -C option as this is an exact match by name (no grep). To enable -C, temporarily define the UNIX95 variable as in:

UNIX95= ps -f -C sh

Finally, shared memory is very complex to assign ownership. The -o vsz option will show Kbytes of local RAM but shared memory is, well, shared. So you'll have to use ipcs -bmop to show the memory used by processes that use shared memory.

NOTE: Using all the RAM (ie, glance shows 100%) is not a bad thing at all. Only when the page-out rate is more than single digits over several minutes is memory usage high and affecting processing speed.

Look at the kernel parameter dbc_max_pct and make sure it is not 50 (1/2 of RAM). Glance will also show you the buffer cache size. Limit the buffer cache to about 400-600 megs, whatever % that is for your RAM size.

To get a picture of the biggest processes (RAM usage), use this basic list:

UNIX95= ps -o vsz,ruser,pid,args | sort -rn


Bill Hassell, sysadmin
Christian Marquardt_1
Regular Advisor

Re: getting number of processes and memory consumption

Thanks for the great help. I'll see what I can do for our development to get some information about forms processes and memory consumption.

kind regards
Christian