<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Report Information about CPU Activity in SQL*Plus</title>
	<atom:link href="http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/</link>
	<description></description>
	<lastBuildDate>Thu, 17 May 2012 06:56:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: Christian Antognini</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-176</link>
		<dc:creator>Christian Antognini</dc:creator>
		<pubDate>Mon, 03 Aug 2009 11:09:42 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-176</guid>
		<description>Mette

&gt; I’m not sure how to calcaulate the number for the cpu usage for the db i’m currently on:

Two corrections and then it should work:

1) You divided v$sys_time_model.value by 100000 instead of 1000000.

2) If you want a percentage based on the number of CPUs, you should use &quot;(l_t2.instance_cpu_time-l_t1.instance_cpu_time)/l_num_cpus/p_interval&quot; to initialize l_out.


HTH
Chris
</description>
		<content:encoded><![CDATA[<p>Mette</p>
<p>> I’m not sure how to calcaulate the number for the cpu usage for the db i’m currently on:</p>
<p>Two corrections and then it should work:</p>
<p>1) You divided v$sys_time_model.value by 100000 instead of 1000000.</p>
<p>2) If you want a percentage based on the number of CPUs, you should use &#8220;(l_t2.instance_cpu_time-l_t1.instance_cpu_time)/l_num_cpus/p_interval&#8221; to initialize l_out.</p>
<p>HTH<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mette</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-175</link>
		<dc:creator>Mette</dc:creator>
		<pubDate>Wed, 29 Jul 2009 13:31:34 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-175</guid>
		<description>Hi - and a wonderfull little thing that I have added to our procedure tool box.  We are outsourced, have muliple db on the same aix box - and do not have access to the AIX OS at all ,,, so every tool is welcome :-)

I have tried to combine with V$SYS_TIME_MODEL, but I&#039;m not sure how to calcaulate the number for the cpu usage for the db i&#039;m currently on:
&lt;pre&gt;

FOR i IN 1..p_count+1
  LOOP
    SELECT systimestamp, sum(decode(stat_name,&#039;IDLE_TIME&#039;, value, NULL)) as idle_time,
           sum(decode(stat_name,&#039;USER_TIME&#039;, value, NULL)) as user_time,
           sum(decode(stat_name,&#039;SYS_TIME&#039;, value, NULL)) as sys_time,
           sum(decode(stat_name,&#039;IOWAIT_TIME&#039;, value, NULL)) as iowait_time,
           sum(decode(stat_name,&#039;NICE_TIME&#039;, value, NULL)) as nice_time
    INTO l_t2.date_time_to, l_t2.idle_time, l_t2.user_time, l_t2.sys_time, l_t2.iowait_time, l_t2.nice_time
    FROM v$osstat
    WHERE stat_name in (&#039;IDLE_TIME&#039;,&#039;USER_TIME&#039;,&#039;SYS_TIME&#039;,&#039;IOWAIT_TIME&#039;,&#039;NICE_TIME&#039;);

    select value/100000
    into l_t2.instance_cpu_time
    from  V$SYS_TIME_MODEL
    where stat_name = &#039;DB CPU&#039;;

    l_out := osstat_record(l_t1.date_time_from, systimestamp,
                           (l_t2.idle_time-l_t1.idle_time)/l_num_cpus/p_interval,
                           (l_t2.user_time-l_t1.user_time)/l_num_cpus/p_interval,
                           (l_t2.sys_time-l_t1.sys_time)/l_num_cpus/p_interval,
                           (l_t2.iowait_time-l_t1.iowait_time)/l_num_cpus/p_interval,
                           (l_t2.nice_time-l_t1.nice_time)/l_num_cpus/p_interval,
                           ((l_t2.instance_cpu_time-l_t1.instance_cpu_time)/p_interval));

    l_total := l_out.idle_time+l_out.user_time+l_out.sys_time+l_out.iowait_time+nvl(l_out.nice_time,0);

    if l_out.user_time &gt; 0 then
       l_instance := (l_out.instance_cpu_time*100)/l_total;
    else
       l_instance := 0;
    end if;

    if i &gt; 1 then
    PIPE ROW(osstat_record(l_t1.date_time_to, systimestamp,
                           trunc((l_out.idle_time/l_total*100),p_dec),
                           trunc((l_out.user_time/l_total*100),p_dec),
                           trunc((l_out.sys_time/l_total*100),p_dec),
                           trunc((l_out.iowait_time/l_total*100),p_dec),
                           trunc((l_out.nice_time/l_total*100),p_dec),
                           trunc(l_instance,p_dec)));
    end if;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi &#8211; and a wonderfull little thing that I have added to our procedure tool box.  We are outsourced, have muliple db on the same aix box &#8211; and do not have access to the AIX OS at all ,,, so every tool is welcome <img src='http://www.antognini.ch/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I have tried to combine with V$SYS_TIME_MODEL, but I&#8217;m not sure how to calcaulate the number for the cpu usage for the db i&#8217;m currently on:</p>
<pre>

FOR i IN 1..p_count+1
  LOOP
    SELECT systimestamp, sum(decode(stat_name,'IDLE_TIME', value, NULL)) as idle_time,
           sum(decode(stat_name,'USER_TIME', value, NULL)) as user_time,
           sum(decode(stat_name,'SYS_TIME', value, NULL)) as sys_time,
           sum(decode(stat_name,'IOWAIT_TIME', value, NULL)) as iowait_time,
           sum(decode(stat_name,'NICE_TIME', value, NULL)) as nice_time
    INTO l_t2.date_time_to, l_t2.idle_time, l_t2.user_time, l_t2.sys_time, l_t2.iowait_time, l_t2.nice_time
    FROM v$osstat
    WHERE stat_name in ('IDLE_TIME','USER_TIME','SYS_TIME','IOWAIT_TIME','NICE_TIME');

    select value/100000
    into l_t2.instance_cpu_time
    from  V$SYS_TIME_MODEL
    where stat_name = 'DB CPU';

    l_out := osstat_record(l_t1.date_time_from, systimestamp,
                           (l_t2.idle_time-l_t1.idle_time)/l_num_cpus/p_interval,
                           (l_t2.user_time-l_t1.user_time)/l_num_cpus/p_interval,
                           (l_t2.sys_time-l_t1.sys_time)/l_num_cpus/p_interval,
                           (l_t2.iowait_time-l_t1.iowait_time)/l_num_cpus/p_interval,
                           (l_t2.nice_time-l_t1.nice_time)/l_num_cpus/p_interval,
                           ((l_t2.instance_cpu_time-l_t1.instance_cpu_time)/p_interval));

    l_total := l_out.idle_time+l_out.user_time+l_out.sys_time+l_out.iowait_time+nvl(l_out.nice_time,0);

    if l_out.user_time > 0 then
       l_instance := (l_out.instance_cpu_time*100)/l_total;
    else
       l_instance := 0;
    end if;

    if i > 1 then
    PIPE ROW(osstat_record(l_t1.date_time_to, systimestamp,
                           trunc((l_out.idle_time/l_total*100),p_dec),
                           trunc((l_out.user_time/l_total*100),p_dec),
                           trunc((l_out.sys_time/l_total*100),p_dec),
                           trunc((l_out.iowait_time/l_total*100),p_dec),
                           trunc((l_out.nice_time/l_total*100),p_dec),
                           trunc(l_instance,p_dec)));
    end if;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: illiyaz</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-174</link>
		<dc:creator>illiyaz</dc:creator>
		<pubDate>Tue, 14 Jul 2009 14:15:12 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-174</guid>
		<description>Superb!!!!!!!!Thanks to you that i ve learnt something new today....</description>
		<content:encoded><![CDATA[<p>Superb!!!!!!!!Thanks to you that i ve learnt something new today&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Antognini</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-173</link>
		<dc:creator>Christian Antognini</dc:creator>
		<pubDate>Mon, 15 Jun 2009 13:24:22 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-173</guid>
		<description>Probably I was not clear in my last reply... Anyway, I wanted to point out the same thing. So, we agree that it is not necessary.</description>
		<content:encoded><![CDATA[<p>Probably I was not clear in my last reply&#8230; Anyway, I wanted to point out the same thing. So, we agree that it is not necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Bajon</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-172</link>
		<dc:creator>Ivan Bajon</dc:creator>
		<pubDate>Mon, 15 Jun 2009 13:07:07 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-172</guid>
		<description>Sorry to be an annoyance here but just tried not dividing by anything. Neither l_num_cpus or p_interval.

&lt;pre&gt;       lout := osstat_record(systimestamp,
                           (l_t2.idle_time-l_t1.idle_time),
                           (l_t2.user_time-l_t1.user_time),
                           (l_t2.sys_time-l_t1.sys_time),
                           (l_t2.iowait_time-l_t1.iowait_time),
                           (l_t2.nice_time-l_t1.nice_time));

DATE_TIM USER_TIME NICE_TIME SYS_TIME IOWAIT_TIME IDLE_TIME
-------- --------- --------- -------- ----------- ---------
05:02:18      6.89      0.00     1.95        0.00     91.15
05:02:19      7.09      0.00     0.73        0.00     92.19
05:02:20      6.68      0.00     0.55        0.00     92.77
05:02:22      6.67      0.00     0.61        0.00     92.72
05:02:23      6.85      0.00     0.73        0.00     92.41&lt;/pre&gt;

It makes sense since you&#039;re dividing each value by the the sum of the values later to get the percentage.

Cheers
Ivan</description>
		<content:encoded><![CDATA[<p>Sorry to be an annoyance here but just tried not dividing by anything. Neither l_num_cpus or p_interval.</p>
<pre>       lout := osstat_record(systimestamp,
                           (l_t2.idle_time-l_t1.idle_time),
                           (l_t2.user_time-l_t1.user_time),
                           (l_t2.sys_time-l_t1.sys_time),
                           (l_t2.iowait_time-l_t1.iowait_time),
                           (l_t2.nice_time-l_t1.nice_time));

DATE_TIM USER_TIME NICE_TIME SYS_TIME IOWAIT_TIME IDLE_TIME
-------- --------- --------- -------- ----------- ---------
05:02:18      6.89      0.00     1.95        0.00     91.15
05:02:19      7.09      0.00     0.73        0.00     92.19
05:02:20      6.68      0.00     0.55        0.00     92.77
05:02:22      6.67      0.00     0.61        0.00     92.72
05:02:23      6.85      0.00     0.73        0.00     92.41</pre>
<p>It makes sense since you&#8217;re dividing each value by the the sum of the values later to get the percentage.</p>
<p>Cheers<br />
Ivan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Antognini</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-171</link>
		<dc:creator>Christian Antognini</dc:creator>
		<pubDate>Mon, 15 Jun 2009 13:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-171</guid>
		<description>Ok, now I understand what do you mean. Since I &quot;reuse&quot; the computed value to compute l_total, there is no difference... Honestly, I don&#039;t remember what I exactly did ;-) But, I guess, I computed the right values just to check them.</description>
		<content:encoded><![CDATA[<p>Ok, now I understand what do you mean. Since I &#8220;reuse&#8221; the computed value to compute l_total, there is no difference&#8230; Honestly, I don&#8217;t remember what I exactly did <img src='http://www.antognini.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  But, I guess, I computed the right values just to check them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Bajon</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-170</link>
		<dc:creator>Ivan Bajon</dc:creator>
		<pubDate>Mon, 15 Jun 2009 12:52:38 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-170</guid>
		<description>Hi Chris

Yes, I get that as far as l_num_cpus go but why p_interval? You can divide by 42 or a million or any other number and the script will still produce correct result with any input values.

Cheers
Ivan</description>
		<content:encoded><![CDATA[<p>Hi Chris</p>
<p>Yes, I get that as far as l_num_cpus go but why p_interval? You can divide by 42 or a million or any other number and the script will still produce correct result with any input values.</p>
<p>Cheers<br />
Ivan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Antognini</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-169</link>
		<dc:creator>Christian Antognini</dc:creator>
		<pubDate>Mon, 15 Jun 2009 12:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-169</guid>
		<description>Hi Ivan

First of all, thank you very much for your feedback.

About your question... I divide by l_num_cpus and p_interval because I want to have a percentage that sums up to 100% and not the absolute values. Ok?

Cheers,
Chris</description>
		<content:encoded><![CDATA[<p>Hi Ivan</p>
<p>First of all, thank you very much for your feedback.</p>
<p>About your question&#8230; I divide by l_num_cpus and p_interval because I want to have a percentage that sums up to 100% and not the absolute values. Ok?</p>
<p>Cheers,<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Bajon</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-168</link>
		<dc:creator>Ivan Bajon</dc:creator>
		<pubDate>Mon, 15 Jun 2009 10:39:03 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-168</guid>
		<description>Hi Chris

There&#039;s this one thing I can&#039;t seem to wrap my head around: why do you divide by p_interval in the lout := osstat_record(systimestamp,...) -statement?

Best regards
Ivan Bajon</description>
		<content:encoded><![CDATA[<p>Hi Chris</p>
<p>There&#8217;s this one thing I can&#8217;t seem to wrap my head around: why do you divide by p_interval in the lout := osstat_record(systimestamp,&#8230;) -statement?</p>
<p>Best regards<br />
Ivan Bajon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Bajon</title>
		<link>http://www.antognini.ch/2009/05/report-information-about-cpu-activity-in-sqlplus/#comment-167</link>
		<dc:creator>Ivan Bajon</dc:creator>
		<pubDate>Wed, 10 Jun 2009 10:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://antognini.ch/?p=242#comment-167</guid>
		<description>Hi Chris

Wonderful tool. It works fine on my Solaris box but on 10.2.0.4/Win2003(64bit) I get all blanks. This can be remedied by replacing the NULLs with 0s in the select statement:

    SELECT sum(decode(stat_name,&#039;IDLE_TIME&#039;, value, 0)) as idle_time,
           sum(decode(stat_name,&#039;USER_TIME&#039;, value, 0)) as user_time,
           sum(decode(stat_name,&#039;SYS_TIME&#039;, value, 0)) as sys_time,
           sum(decode(stat_name,&#039;IOWAIT_TIME&#039;, value, 0)) as iowait_time,
           sum(decode(stat_name,&#039;NICE_TIME&#039;, value, 0)) as nice_time
    INTO l_t2.idle_time, l_t2.user_time, l_t2.sys_time, l_t2.iowait_time, l_t2.nice_time
    FROM sys.v_$osstat
    WHERE stat_name in (&#039;IDLE_TIME&#039;,&#039;USER_TIME&#039;,&#039;SYS_TIME&#039;,&#039;IOWAIT_TIME&#039;,&#039;NICE_TIME&#039;);

Best regards
Ivan Bajon</description>
		<content:encoded><![CDATA[<p>Hi Chris</p>
<p>Wonderful tool. It works fine on my Solaris box but on 10.2.0.4/Win2003(64bit) I get all blanks. This can be remedied by replacing the NULLs with 0s in the select statement:</p>
<p>    SELECT sum(decode(stat_name,&#8217;IDLE_TIME&#8217;, value, 0)) as idle_time,<br />
           sum(decode(stat_name,&#8217;USER_TIME&#8217;, value, 0)) as user_time,<br />
           sum(decode(stat_name,&#8217;SYS_TIME&#8217;, value, 0)) as sys_time,<br />
           sum(decode(stat_name,&#8217;IOWAIT_TIME&#8217;, value, 0)) as iowait_time,<br />
           sum(decode(stat_name,&#8217;NICE_TIME&#8217;, value, 0)) as nice_time<br />
    INTO l_t2.idle_time, l_t2.user_time, l_t2.sys_time, l_t2.iowait_time, l_t2.nice_time<br />
    FROM sys.v_$osstat<br />
    WHERE stat_name in (&#8216;IDLE_TIME&#8217;,'USER_TIME&#8217;,'SYS_TIME&#8217;,'IOWAIT_TIME&#8217;,'NICE_TIME&#8217;);</p>
<p>Best regards<br />
Ivan Bajon</p>
]]></content:encoded>
	</item>
</channel>
</rss>

