<?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: Oracle capacity planning with RRDTOOL</title>
	<atom:link href="http://www.ludovicocaldara.net/dba/oracle-capacity-planning-with-rrdtool/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ludovicocaldara.net/dba/oracle-capacity-planning-with-rrdtool/</link>
	<description>Keep DBA job simple. Thanks.</description>
	<lastBuildDate>Mon, 21 Dec 2009 15:26:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: amihay gonen</title>
		<link>http://www.ludovicocaldara.net/dba/oracle-capacity-planning-with-rrdtool/comment-page-1/#comment-363</link>
		<dc:creator>amihay gonen</dc:creator>
		<pubDate>Mon, 21 Dec 2009 15:26:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=68#comment-363</guid>
		<description>#!/bin/bash

# here is porting to bash  - i like the idea . 


set -o nounset
set -o errexit


# global vars
mysql=&quot;sqlplus -s -l &quot;
connstr=system/system@ora10
rrdpath=/usr/local/rrdtool-1.2.19/bin
rrd=$rrdpath/rrdtool 
WD=`pwd`

function docmd()
{
  [ &quot;$1&quot; = &quot;&quot; ] &amp;&amp; return 0
  echo &quot;$1\n.&quot;
  eval &quot;$1&quot;
  return $?
}
#docmd 

function createRRD() {
		local name=$1
		local interval=$2
		local cs=$3
        local hb=$((interval*5)); #heartbeat
        local cmd=&quot;$rrd create $WD/${name}.rrd -s${interval} DS:waits:DERIVE:$hb:0:U DS:mswaited:DERIVE:$hb:0:U RRA:AVERAGE:0.5:1:1440 RRA:AVERAGE:0.5:30:336 RRA:AVERAGE:0.5:120:372 RRA:AVERAGE:0.5:720:730 RRA:MIN:0.5:1:1440 RRA:MIN:0.5:30:336  RRA:MIN:0.5:120:372 RRA:MIN:0.5:720:730 RRA:MAX:0.5:1:1440 RRA:MAX:0.5:30:336 RRA:MAX:0.5:120:372 RRA:MAX:0.5:720:730  RRA:LAST:0.5:1:1440&quot;
        docmd &quot;$cmd&quot; &#124;&#124; return $?				
        return 0;
}                                                                              
#createRRD

#/* take the snapshot frequency from dba_hist_wr_control to create the RDD with correct heartbeat value */
sql=&quot;select extract(hour from snap_interval)*3600 + extract(minute from snap_interval)*60 as SEED from DBA_HIST_WR_CONTROL&quot;
interval=` ${mysql} ${connstr}&lt;$outfile&lt;100000
  and s.instance_number=i.instance_number
  and s.instance_number=g.instance_number)
 order by event_name, END_INTERVAL_TIME;
END


i=0
oldevent=&quot;&quot;
cmd=&quot;&quot;
last=&quot;0&quot;
cat $outfile &#124; while IFS=, read end_interval_time event_name wait_class total_waits ms; do
	if [ &quot;$oldevent&quot; != &quot;$event_name&quot; ]; then
#                //NEW EVENT DETECTED: WILL START A NEW UPDATE CMD
		[ ! &quot;$i&quot; -eq &quot;0&quot; -a &quot;$cmd&quot; != &quot;&quot; ] &amp;&amp; docmd &quot;$cmd&quot;	   
		echo event=$event_name
		cleanName=${event_name// /_}
		cleanName=${cleanName//:/_}
		# if there is no rrd for this event, I create a new one
		[ ! -f &quot;${WD}/${cleanName}.rrd&quot; ] &amp;&amp;  createRRD &quot;$cleanName&quot; &quot;$interval&quot; &quot;&quot;
		#       * I initialize a new update command. This string act as a buffer: I append many        values to be updated so I&#039;ll update many values in a single command line:
		#                * less forks of rrdtool and less file opens: the whole update process has an  enormous improvement.

		precmd=&quot;$rrd update $WD/${cleanName}.rrd&quot;
        last=`$rrd info $WD/${cleanName}.rrd&#124; grep last_update &#124; awk &#039;{print \$NF}&#039;`
		last=${last:-0}
		printf &quot;%s - %s - last: %d\n&quot; &quot;$event_name&quot; &quot;$cleanName&quot; &quot;$last&quot;
         i=0;
         cmd=&quot;$precmd&quot;
         oldevent=&quot;$event_name&quot;
	fi
	time=$end_interval_time
#      //print &quot;time: &quot;.$time.&quot;  last: &quot;.$last.&quot;\n&quot;;
    if [ &quot;$time&quot; -gt &quot;$last&quot; ]; then
		cmd=&quot;$cmd ${time}:${total_waits}:${ms}&quot;
		i=$(($i+1))
	fi
	if [ &quot;$i&quot; -gt &quot;40&quot; ]; then
#                // when I reach 40 values per commandline I force
#                // the update: next loop will reinitialize a new commandline.
		docmd &quot;$cmd&quot;
		cmd=&quot;$precmd&quot;
		i=0
	fi
done
[ &quot;$i&quot; -eq &quot;0&quot; ] &#124;&#124; docmd $cmd

[ -f &quot;$outfile&quot; ] &amp;&amp; rm &quot;$outfile&quot;
echo done in $SECONDS</description>
		<content:encoded><![CDATA[<p>#!/bin/bash</p>
<p># here is porting to bash  &#8211; i like the idea . </p>
<p>set -o nounset<br />
set -o errexit</p>
<p># global vars<br />
mysql=&#8221;sqlplus -s -l &#8221;<br />
connstr=system/system@ora10<br />
rrdpath=/usr/local/rrdtool-1.2.19/bin<br />
rrd=$rrdpath/rrdtool<br />
WD=`pwd`</p>
<p>function docmd()<br />
{<br />
  [ "$1" = "" ] &amp;&amp; return 0<br />
  echo &#8220;$1\n.&#8221;<br />
  eval &#8220;$1&#8243;<br />
  return $?<br />
}<br />
#docmd </p>
<p>function createRRD() {<br />
		local name=$1<br />
		local interval=$2<br />
		local cs=$3<br />
        local hb=$((interval*5)); #heartbeat<br />
        local cmd=&#8221;$rrd create $WD/${name}.rrd -s${interval} DS:waits:DERIVE:$hb:0:U DS:mswaited:DERIVE:$hb:0:U RRA:AVERAGE:0.5:1:1440 RRA:AVERAGE:0.5:30:336 RRA:AVERAGE:0.5:120:372 RRA:AVERAGE:0.5:720:730 RRA:MIN:0.5:1:1440 RRA:MIN:0.5:30:336  RRA:MIN:0.5:120:372 RRA:MIN:0.5:720:730 RRA:MAX:0.5:1:1440 RRA:MAX:0.5:30:336 RRA:MAX:0.5:120:372 RRA:MAX:0.5:720:730  RRA:LAST:0.5:1:1440&#8243;<br />
        docmd &#8220;$cmd&#8221; || return $?<br />
        return 0;<br />
}<br />
#createRRD</p>
<p>#/* take the snapshot frequency from dba_hist_wr_control to create the RDD with correct heartbeat value */<br />
sql=&#8221;select extract(hour from snap_interval)*3600 + extract(minute from snap_interval)*60 as SEED from DBA_HIST_WR_CONTROL&#8221;<br />
interval=` ${mysql} ${connstr}&lt;$outfile&lt;100000<br />
  and s.instance_number=i.instance_number<br />
  and s.instance_number=g.instance_number)<br />
 order by event_name, END_INTERVAL_TIME;<br />
END</p>
<p>i=0<br />
oldevent=&#8221;"<br />
cmd=&#8221;"<br />
last=&#8221;0&#8243;<br />
cat $outfile | while IFS=, read end_interval_time event_name wait_class total_waits ms; do<br />
	if [ "$oldevent" != "$event_name" ]; then<br />
#                //NEW EVENT DETECTED: WILL START A NEW UPDATE CMD<br />
		[ ! "$i" -eq "0" -a "$cmd" != "" ] &amp;&amp; docmd &#8220;$cmd&#8221;<br />
		echo event=$event_name<br />
		cleanName=${event_name// /_}<br />
		cleanName=${cleanName//:/_}<br />
		# if there is no rrd for this event, I create a new one<br />
		[ ! -f "${WD}/${cleanName}.rrd" ] &amp;&amp;  createRRD &#8220;$cleanName&#8221; &#8220;$interval&#8221; &#8220;&#8221;<br />
		#       * I initialize a new update command. This string act as a buffer: I append many        values to be updated so I&#8217;ll update many values in a single command line:<br />
		#                * less forks of rrdtool and less file opens: the whole update process has an  enormous improvement.</p>
<p>		precmd=&#8221;$rrd update $WD/${cleanName}.rrd&#8221;<br />
        last=`$rrd info $WD/${cleanName}.rrd| grep last_update | awk &#8216;{print \$NF}&#8217;`<br />
		last=${last:-0}<br />
		printf &#8220;%s &#8211; %s &#8211; last: %d\n&#8221; &#8220;$event_name&#8221; &#8220;$cleanName&#8221; &#8220;$last&#8221;<br />
         i=0;<br />
         cmd=&#8221;$precmd&#8221;<br />
         oldevent=&#8221;$event_name&#8221;<br />
	fi<br />
	time=$end_interval_time<br />
#      //print &#8220;time: &#8220;.$time.&#8221;  last: &#8220;.$last.&#8221;\n&#8221;;<br />
    if [ "$time" -gt "$last" ]; then<br />
		cmd=&#8221;$cmd ${time}:${total_waits}:${ms}&#8221;<br />
		i=$(($i+1))<br />
	fi<br />
	if [ "$i" -gt "40" ]; then<br />
#                // when I reach 40 values per commandline I force<br />
#                // the update: next loop will reinitialize a new commandline.<br />
		docmd &#8220;$cmd&#8221;<br />
		cmd=&#8221;$precmd&#8221;<br />
		i=0<br />
	fi<br />
done<br />
[ "$i" -eq "0" ] || docmd $cmd</p>
<p>[ -f "$outfile" ] &amp;&amp; rm &#8220;$outfile&#8221;<br />
echo done in $SECONDS</p>
]]></content:encoded>
	</item>
</channel>
</rss>
