cpu usage by a db [message #563725] |
Thu, 16 August 2012 11:33 |
|
akh555
Messages: 3 Registered: August 2012
|
Junior Member |
|
|
Hi,
I have three oracle 10g databases (db1, db2, db3)on a linux box.
can anyone help me with a command at the OS level to find total cpu used by each of the above databases.
thank you for your help in advance.
|
|
|
|
|
|
|
Re: cpu usage by a db [message #563738 is a reply to message #563735] |
Thu, 16 August 2012 12:48 |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
As BlackSwan said, the OS does know nothing about which process ID belongs to which instance. On the other hand, Oracle knows nothing about the actual load on the CPUs.
So there is no ready-made built-in way to get that information.
|
|
|
|
|
Re: cpu usage by a db [message #563764 is a reply to message #563763] |
Thu, 16 August 2012 19:22 |
|
alan.kendall@nfl.com
Messages: 163 Registered: June 2012 Location: Culver City, California
|
Senior Member |
|
|
I left out part of the sql to get the daily hit ratios. The full sql follows.
SET LINES 200
SET WRAP OFF
col "DAY" for a20
col hit_ratio for 999.9
set termout off
drop table alan_logical purge;
drop table alan_physical purge;
break on report
compute sum of total_daily_logical_reads on report
create table alan_logical as
select to_char(c.BEGIN_INTERVAL_TIME,'YYYY-MM-DD Day') "DAT",
sum(b.logical_READS_DELTA) total_logical
from dba_objects a,dba_hist_seg_stat b,sys.wRM$_SNAPSHOT c
where a.object_id=b.OBJ#
and b.logical_READS_DELTA>0
and c.instance_number=(select instance_number from v$instance)
and c.snap_id=b.snap_id
group by to_char(c.BEGIN_INTERVAL_TIME,'YYYY-MM-DD Day')
order by 1,2
/
create table alan_physical as
select to_char(c.BEGIN_INTERVAL_TIME,'YYYY-MM-DD Day') "DAT",
sum(b.physical_READS_DELTA) total_physical
from dba_objects a,dba_hist_seg_stat b,sys.wRM$_SNAPSHOT c
where a.object_id=b.OBJ#
and b.physical_READS_DELTA>0
and c.instance_number=(select instance_number from v$instance)
and c.snap_id=b.snap_id
group by to_char(c.BEGIN_INTERVAL_TIME,'YYYY-MM-DD Day')
order by 1,2
/
set termout on
select d.name database,l.dat "Day",total_logical logical,total_physical physical,
total_logical/(total_physical+total_logical)*100 Hit_ratio
from alan_physical p, alan_logical l,v$database d
where p.dat=l.dat;
|
|
|
|
Re: cpu usage by a db [message #564708 is a reply to message #564613] |
Mon, 27 August 2012 14:15 |
John Watson
Messages: 8960 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
You might have more answers if you had said what operating system you use. Let's assume it is Linux.
Assuming that each database instance is running under a different user (as it should be), then use top to extract the processes run by that user, and send the results to awk to sum up the CPU usage. So for user prod,
top -b -n1 -u prod | awk '{ sum += $9; } END { print sum; }'
|
|
|
|
Re: cpu usage by a db [message #564710 is a reply to message #564709] |
Mon, 27 August 2012 14:28 |
John Watson
Messages: 8960 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
So that you can do things like summing up CPU usage per user! I would think that security and separation of duties would be important too. I have had it drilled into me for as long as I can remember that shared accounts (for OS or database) are a no-no. Purely an administration thing of course, no technical significance.
|
|
|