<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DBA survival BLOG &#187; Linux</title>
	<atom:link href="http://www.ludovicocaldara.net/dba/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ludovicocaldara.net/dba</link>
	<description>Keep DBA job simple. Thanks.</description>
	<lastBuildDate>Thu, 27 Aug 2009 13:58:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A great talk</title>
		<link>http://www.ludovicocaldara.net/dba/a-great-talk/</link>
		<comments>http://www.ludovicocaldara.net/dba/a-great-talk/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 08:16:02 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=79</guid>
		<description><![CDATA[John Allspaw and Paul Hammond (Flickr) talk about Dev and Ops Cooperation at Flickr (very good).
 
Have a look at Kitchen Soap blog.
]]></description>
			<content:encoded><![CDATA[<p>John Allspaw and Paul Hammond (Flickr) talk about Dev and Ops Cooperation at Flickr (very good).</p>
<p><embed src="http://blip.tv/play/AYGMoH+LqzQ" type="application/x-shockwave-flash" width="460" height="390" allowscriptaccess="always" allowfullscreen="true"></embed> </p>
<p>Have a look at <a href="http://www.kitchensoap.com/2009/06/23/slides-for-velocity-talk-2009/">Kitchen Soap</a> blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/a-great-talk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to collect Oracle Application Server performance data with DMS and RRDtool</title>
		<link>http://www.ludovicocaldara.net/dba/how-to-collect-oracle-application-server-performance-data-with-dms-and-rrdtool/</link>
		<comments>http://www.ludovicocaldara.net/dba/how-to-collect-oracle-application-server-performance-data-with-dms-and-rrdtool/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 17:08:31 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Application Server]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Capacity Planning]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=56</guid>
		<description><![CDATA[RRDize everything, chapter 1
If you are managing some Application Server deployments you should have wondered how to check and collect performance data.
As stated in documentation, you can gather performance metrics with the dmstool utility.
AFAIK, this can be done from 9.0.2 release upwards, but i&#8217;m concerned DMS will not work on Weblogic.
Mainly, you should have an [...]]]></description>
			<content:encoded><![CDATA[<p><strong>RRDize everything, chapter 1</strong></p>
<p>If you are managing some Application Server deployments you should have wondered how to check and collect performance data.<br />
As stated in documentation, you can gather performance metrics with the dmstool utility.<br />
AFAIK, this can be done from 9.0.2 release upwards, but i&#8217;m concerned DMS will not work on Weblogic.</p>
<p>Mainly, you should have an external server that acts as collector (it could be a server in the Oracle AS farm as well): copy the dms.jar library from an Oracle AS installation to your collector and use it as you would use dmstool:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">java -jar dms.jar [dmstool options]</pre></div></div>

<p>There are three basilar methods to get data:</p>
<p>Get all metrics at once:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">java -jar dms.jar -dump -a &quot;youraddress://...&quot; [format=xml]</pre></div></div>

<p>Get only the interesting metrics:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">java -jar dms.jar -a &quot;youraddress://...&quot; metric metric ...</pre></div></div>

<p>Get metrics included into specific DMS tables:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">java -jar dms.jar -a &quot;youraddress://...&quot; -table table table ...</pre></div></div>

<p>What youraddress:// is, it depends on the component you are trying to connect:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">opmn://asserver:6003
http://asserver:7200/dms0/Spy
ajp13://asserver:3301/dmsoc4j/Spy</pre></div></div>

<p>If you are trying to connect to the OHS (Apache), be careful to allow remote access from the collector by editing the dms.conf file.</p>
<p>Now that you can query dms data, you should store it somewhere.<br />
Personally, I did a first attempt with dmstool -dump format=xml. I wrote a parser in PHP with SimpleXML extension and I did a lot of inserts into a MySQL database. After a few months the whole data collected from tens of servers was too much to be mantained&#8230;<br />
To avoid the maintenance of a DWH-grade database I investigated and found RRDTool. Now I&#8217;m asking how could I live without it!</p>
<p>I then wrote a parser in awk that parse the output of the dms.jar call and invoke an rrdtool update command.<br />
I always use dms.jar -table command. The output has always the same format:</p>
<pre>###SOF

Mon Mar 02 17:01:19 CET 2009

---------------
TABLE1_Name
---------------

record1_metric1.name:     value       units
record1_metric2.name:     value       units
....

record2_metric1.name:     value       units
record2_metric2.name:     value       units
....

---
TABLE2_Name
---

record1_metric1.name:     value       units
record1_metric2.name:     value       units
....

record2_metric1.name:     value       units
record2_metric2.name:     value       units
....

##EOF</pre>
<p>So I written an awk file that works for me.<br />
use it this way:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"> java -jar dms.jar ... | awk -f parse_output.awk</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">####################</span>
<span style="color: #339933;"># parse_output.awk #</span>
<span style="color: #339933;">####################</span>
&nbsp;
<span style="color: #339933;">#function pl() replaces all non alphanumeric occurrences with an underscore</span>
<span style="color: #000000; font-weight: bold;">function</span> pl<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> gensub<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;[^[:alnum:]_-]&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;_&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;G&quot;</span><span style="color: #339933;">,</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;"># function get_rrd_path() returns a path where the rrd files should be placed</span>
<span style="color: #339933;"># I should rewrite a new path for each dms table... I'll skip many of them</span>
<span style="color: #000000; font-weight: bold;">function</span> get_rrd_path<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>table <span style="color: #339933;">==</span> <span style="color: #ff0000;">&quot;mod_oc4j_destination_metrics&quot;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s/%s/%s/%s.rrd&quot;</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                    pl<span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Name.value&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>var<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>table <span style="color: #339933;">==</span> <span style="color: #ff0000;">&quot;mod_oc4j_mount_pt_metrics&quot;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s/%s/%s/%s/%s.rrd&quot;</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                    pl<span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Destination.value&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Name.value&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>var<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>table <span style="color: #339933;">==</span> <span style="color: #ff0000;">&quot;ohs_server&quot;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s/%s/%s.rrd&quot;</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>var<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>table <span style="color: #339933;">==</span> <span style="color: #ff0000;">&quot;JVM&quot;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s/%s/%s/%s.rrd&quot;</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                    pl<span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Process&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>var<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>table <span style="color: #339933;">==</span> <span style="color: #ff0000;">&quot;opmn_process&quot;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s/%s/%s/%s/%s/%s/%s/%s.rrd&quot;</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                  pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;iasInstance.value&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;opmn_ias_component&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                  pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;opmn_process_type&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;opmn_process_set&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                  pl<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>var<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s/%s/%s.rrd&quot;</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pl<span style="color: #009900;">&#40;</span>var<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;"># function process_record actually does the dirty work of invoking the update script</span>
<span style="color: #000000; font-weight: bold;">function</span> process_record<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #339933;">#every record has a timeStamp.ts metric that I should use to update my rrd</span>
        ts<span style="color: #339933;">=</span>substr<span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;timeStamp.ts&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> var in record <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> var <span style="color: #339933;">!=</span> <span style="color: #ff0000;">&quot;timeStamp.ts&quot;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> record<span style="color: #009900;">&#91;</span>var<span style="color: #009900;">&#93;</span> ~ <span style="color: #339933;">/^</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">:</span>digit<span style="color: #339933;">:</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>$<span style="color: #339933;">/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> var ~ <span style="color: #339933;">/</span>\.<span style="color: #009900;">&#40;</span>count<span style="color: #339933;">|</span>completed<span style="color: #339933;">|</span>time<span style="color: #009900;">&#41;</span>$<span style="color: #339933;">/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                dstype<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;DERIVE&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> var <span style="color: #339933;">==</span> <span style="color: #ff0000;">&quot;responseSize.value&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    dstype<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;DERIVE&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                    dstype<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;GAUGE&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            rrdFile<span style="color: #339933;">=</span>sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;/path_to_data/%s&quot;</span><span style="color: #339933;">,</span>get_rrd_path<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #339933;">#### update_metric_rrd is a shell script listed below!!!!!</span>
            cmd<span style="color: #339933;">=</span>sprintf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;/path_to_scripts/update_metric_rrd %s %s %d %d&quot;</span><span style="color: #339933;">,</span>
                rrdFile<span style="color: #339933;">,</span>dstype<span style="color: #339933;">,</span>ts<span style="color: #339933;">,</span>record<span style="color: #009900;">&#91;</span>var<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            system<span style="color: #009900;">&#40;</span>cmd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;"># parse_record() populates an hash array</span>
<span style="color: #339933;"># with all metrics belonging to the table record</span>
<span style="color: #000000; font-weight: bold;">function</span> parse_record<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #339933;">#print &quot;RRRR -  START OF RECORD (table &quot; table &quot;)&quot;</span>
    delete record
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">/^</span>$<span style="color: #339933;">/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #339933;"># I'm parsing the record as far I'm in this while statement</span>
        <span style="color: #339933;"># the array hash is the name of the dms metric basename.</span>
        <span style="color: #339933;"># $1 is the metric name but I have to trim the final &quot;:&quot;</span>
        key<span style="color: #339933;">=</span>substr<span style="color: #009900;">&#40;</span>$<span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span>length<span style="color: #009900;">&#40;</span>$<span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
        record<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>$<span style="color: #0000dd;">2</span>
        getline
    <span style="color: #009900;">&#125;</span>
    <span style="color: #339933;"># this function is included in funcions.awk:</span>
    <span style="color: #339933;"># I invoke it to process the record I've just parsed</span>
    process_record<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
BEGIN <span style="color: #009900;">&#123;</span>
    <span style="color: #339933;"># as far as started is 0, I've never reached the first table</span>
    started<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">#MAIN</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #339933;"># I jump over the first lines until I reach the first table</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>started<span style="color: #339933;">==</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">/^---/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           getline
        <span style="color: #009900;">&#125;</span>
        started<span style="color: #339933;">=</span><span style="color: #0000dd;">1</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #339933;"># looking for the next occurrence of a table</span>
    <span style="color: #339933;"># all tables start with:</span>
    <span style="color: #339933;"># ----------</span>
    <span style="color: #339933;"># table_name</span>
    <span style="color: #339933;"># ----------</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">/^---/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #339933;"># first table reached: the next row is my table name,</span>
        <span style="color: #339933;"># then I reach again a dashed line -----</span>
        getline table
        getline trash
        <span style="color: #339933;">#print &quot;&quot;</span>
        <span style="color: #339933;">#print &quot;##########################&quot;</span>
        print <span style="color: #ff0000;">&quot;  TABELLA &quot;</span> table
        <span style="color: #339933;">#print &quot;##########################&quot;</span>
        next
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #339933;">/^</span>$<span style="color: #339933;">/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #339933;"># reached an empty line: could be the end of a record or the and of a table</span>
        <span style="color: #339933;"># since a new table is threated in previous &quot;if&quot; statement, I'm starting a new record.</span>
        parse_record<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
END <span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And this is the code for update_metric_rrd:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">RRDFILE</span>=$<span style="color: #000000;">1</span>
<span style="color: #007800;">DSTYPE</span>=$<span style="color: #000000;">2</span>
<span style="color: #007800;">TS</span>=$<span style="color: #000000;">3</span>
<span style="color: #007800;">VALUE</span>=$<span style="color: #000000;">4</span>
&nbsp;
rrdtool update <span style="color: #007800;">$RRDFILE</span> <span style="color: #800000;">${TS}</span>:<span style="color: #800000;">${VALUE}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">DIR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #007800;">$RRDFILE</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$DIR</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$DIR</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$RRDFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> rrdtool create <span style="color: #007800;">$RRDFILE</span> <span style="color: #660033;">-b</span> <span style="color: #ff0000;">&quot;now-1month&quot;</span> <span style="color: #660033;">-s</span> <span style="color: #000000;">1800</span> \
                DS:metric:<span style="color: #800000;">${DSTYPE}</span>:<span style="color: #000000;">7200</span>:<span style="color: #000000;">0</span>:U \
                RRA:AVERAGE:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">1</span>:<span style="color: #000000;">672</span> \
                RRA:AVERAGE:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">4</span>:<span style="color: #000000;">1080</span> \
                RRA:AVERAGE:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">1460</span> \
                RRA:AVERAGE:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">48</span>:<span style="color: #000000;">1095</span> \
                RRA:MAX:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">4</span>:<span style="color: #000000;">1080</span> \
                RRA:MAX:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">1460</span> \
                RRA:MAX:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">48</span>:<span style="color: #000000;">1095</span> \
                RRA:LAST:<span style="color: #000000;">0.5</span>:<span style="color: #000000;">1</span>:<span style="color: #000000;">672</span>
        rrdtool update <span style="color: #007800;">$RRDFILE</span> <span style="color: #800000;">${TS}</span>:<span style="color: #800000;">${VALUE}</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Once you have all your rrd files populated, it&#8217;s easy to script automatic reporting. You would probably want a graph with the request count served by your Apache cluster, along with its linear regression:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rrdtool graph - <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;end-<span style="color: #007800;">${hours}</span>hours&quot;</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$end</span> \
                <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;Requests Completed/sec&quot;</span> \
        <span style="color: #660033;">-w</span> <span style="color: #000000;">640</span> <span style="color: #660033;">-h</span> <span style="color: #000000;">240</span> <span style="color: #660033;">--slope-mode</span> \
                <span style="color: #660033;">-t</span> <span style="color: #ff0000;">&quot;HTTP Requests for www.ludovicocaldara.net&quot;</span> \
                DEF:<span style="color: #000000;">1</span><span style="color: #007800;">request_completed</span>=<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>wwwserver1<span style="color: #000000; font-weight: bold;">/</span>ohs_server<span style="color: #000000; font-weight: bold;">/</span>request_completed.rrd:metric:AVERAGE \
                DEF:<span style="color: #000000;">2</span><span style="color: #007800;">request_completed</span>=<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>wwwserver2<span style="color: #000000; font-weight: bold;">/</span>ohs_server<span style="color: #000000; font-weight: bold;">/</span>request_completed.rrd:metric:AVERAGE \
                CDEF:<span style="color: #007800;">request_completed</span>=1request_completed,2request_completed,+ \
                VDEF:<span style="color: #007800;">slope</span>=request_completed,LSLSLOPE \
                VDEF:<span style="color: #007800;">lslint</span>=request_completed,LSLINT \
                CDEF:<span style="color: #007800;">reg</span>=request_completed,POP,slope,COUNT,<span style="color: #000000; font-weight: bold;">*</span>,lslint,+ \
                LINE1:reg<span style="color: #666666; font-style: italic;">#666666:&quot;Regression&quot; \</span>
                AREA:1request_completed<span style="color: #666666; font-style: italic;">#4040AA:&quot;wwwserver1&quot;  \</span>
                AREA:2request_completed<span style="color: #666666; font-style: italic;">#6666FF:&quot;wwwserver1&quot;:STACK  \</span>
        <span style="color: #000000; font-weight: bold;">&amp;</span>gt; mygraph.png</pre></div></div>

<p>This is the result:<br />
<img src="http://www.ludovicocaldara.net/images/dba/dms_ohs_requests.png" alt="OHS request completed" /><br />
<strong>OHHHHHHHHHHHH!!!! COOL!!!!</strong></p>
<p>That&#8217;s all for DMS capacity planning. Stay tuned, more about rrdtool is coming!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/how-to-collect-oracle-application-server-performance-data-with-dms-and-rrdtool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interesting Slides about Capacity Planning</title>
		<link>http://www.ludovicocaldara.net/dba/interesting-slides-about-capacity-planning/</link>
		<comments>http://www.ludovicocaldara.net/dba/interesting-slides-about-capacity-planning/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 21:43:17 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Capacity Planning]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=46</guid>
		<description><![CDATA[Browsing the web I found this interesting presentation by John Allspaw:
Slides from ‘Capacity Planning for LAMP’ talk at MySQL Conf 2007.
(Damn, I had to clean out the embedded flash because of invalid markup&#8230;)

I&#8217;m preparing some stuff related to RRDTool, I&#8217;ll post soon here some code snippets.
]]></description>
			<content:encoded><![CDATA[<p>Browsing the web I found this interesting presentation by <b>John Allspaw</b>:</p>
<p><a title="View Slides from ‘Capacity Planning for LAMP’ talk at MySQL Conf 2007 on Scribd" href="http://www.scribd.com/doc/43281/Slides-from-Capacity-Planning-for-LAMP-talk-at-MySQL-Conf-2007" style="margin: 12px auto 6px auto; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; display: block; text-decoration: underline;">Slides from ‘Capacity Planning for LAMP’ talk at MySQL Conf 2007</a>.<br />
(Damn, I had to clean out the embedded flash because of invalid markup&#8230;)<br />
<br />
I&#8217;m preparing some stuff related to <a href="http://oss.oetiker.ch/rrdtool/">RRDTool</a>, I&#8217;ll post soon here some code snippets.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/interesting-slides-about-capacity-planning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awk snippet to count TCP sockets grouped by state</title>
		<link>http://www.ludovicocaldara.net/dba/awk-snippet-to-count-tcp-sockets-grouped-by-state/</link>
		<comments>http://www.ludovicocaldara.net/dba/awk-snippet-to-count-tcp-sockets-grouped-by-state/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 15:47:04 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=42</guid>
		<description><![CDATA[Depending on the release of awk it could be:

#!/usr/bin/gawk -f
&#123;
        if &#40; &#40;$NF&#41; in stats &#41;  &#123;
                stats&#91;$NF&#93; = stats&#91;$NF&#93;+1;
        &#125; else &#123;
   [...]]]></description>
			<content:encoded><![CDATA[<p>Depending on the release of awk it could be:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#!/usr/bin/gawk -f</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>$NF<span style="color: #009900;">&#41;</span> in stats <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
                stats<span style="color: #009900;">&#91;</span>$NF<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> stats<span style="color: #009900;">&#91;</span>$NF<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                stats<span style="color: #009900;">&#91;</span>$NF<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
END <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> var in stats<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                print var <span style="color: #ff0000;">&quot; = &quot;</span> stats<span style="color: #009900;">&#91;</span>var<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I saved the script as <b>netstat_c</b>.<br />
I have to filter my netstat output to match only my tcp sockets prior to pipe the output to the script.</p>
<p>On linux:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ netstat -a | grep ^tcp | netstat_c
LISTEN = 13
ESTABLISHED = 74
TIME_WAIT = 7</pre></div></div>

<p>This is great to check my webserver connections when I do stress tests.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/awk-snippet-to-count-tcp-sockets-grouped-by-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Oracle Dataguard check script</title>
		<link>http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/</link>
		<comments>http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 15:49:10 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle Dataguard]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=38</guid>
		<description><![CDATA[Oracle Dataguard has his own command-line dgmgrl to check the whole dataguard configuration status.
At least you should check that the show configuration command returns SUCCESS.
This is an hypothetic script:

#!/bin/bash
export ORACLE_HOME=/u1/app/oracle/product/10.2.0
export ORACLE_SID=orcldg
result=`echo &#34;show configuration;&#34; &#124; \
  $ORACLE_HOME/bin/dgmgrl sys/strongpasswd &#124; \
  grep -A 1 &#34;Current status for&#34; &#124; grep -v &#34;Current status for&#34;`
if &#91; &#34;$result&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle Dataguard has his own command-line <i>dgmgrl</i> to check the whole dataguard configuration status.<br />
At least you should check that the <i>show configuration</i> command returns <b>SUCCESS</b>.</p>
<p>This is an hypothetic script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ORACLE_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>u1<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>product<span style="color: #000000; font-weight: bold;">/</span>10.2.0
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ORACLE_SID</span>=orcldg
<span style="color: #007800;">result</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;show configuration;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> \
  <span style="color: #007800;">$ORACLE_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dgmgrl sys<span style="color: #000000; font-weight: bold;">/</span>strongpasswd <span style="color: #000000; font-weight: bold;">|</span> \
  <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-A</span> <span style="color: #000000;">1</span> <span style="color: #ff0000;">&quot;Current status for&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;Current status for&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$result</span>&quot;</span> = <span style="color: #ff0000;">&quot;SUCCESS&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Another script should check for the gap between production online log and the log stream received by the standby database. This can be accomplished with v$managed_standby view.<br />
The Total Block Gap between production and standby can be calculated this way:<br />
Sum all blocks from v$archived_logs where seq# between  Current Standby Seq# and Current Production Seq#.  Then add current block# of the production LGWR process and subtract current block# from RFS standby process. This gives you total blocks even if there is a log sequence gap between sites.<br />
This is NOT the gap of online log APPLIED to the standby database. THIS IS THE GAP OF ONLINE LOG TRANSMITTED TO THE STANDBY RFS PROCESS and can be used to monitor your dataguard transmission from production to disaster recovery environment.</p>
<p>This is an excerpt of such script (please take care that it does not check against RFS failures, so it can fails when RFS is not alive):</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/u1/app/oracle/product/10.2.0/perl/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> DBI<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> DBD<span style="color: #339933;">::</span><span style="color: #006600;">Oracle</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">:</span>ora_session_modes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># DB connection #</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$prod</span>  <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;orclprod&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$stby</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;orcldr&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$prodh</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$prodh</span> <span style="color: #339933;">=</span> DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'dbi:Oracle:'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$prod</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'sys'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'strongpassword'</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span>PrintError<span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> AutoCommit <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
  ora_session_mode <span style="color: #339933;">=&gt;</span> ORA_SYSDBA<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Error connecting to DB: $DBI::errstr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>RaiseError<span style="color: #009900;">&#125;</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$stbyh</span> <span style="color: #339933;">=</span> DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'dbi:Oracle:'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$stby</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'sys'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'strongpassword'</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span>PrintError<span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> AutoCommit <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
  ora_session_mode <span style="color: #339933;">=&gt;</span> ORA_SYSDBA<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Error connecting to DB: $DBI::errstr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>RaiseError<span style="color: #009900;">&#125;</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">### query prod</span>
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">select</span> SEQUENCE<span style="color: #666666; font-style: italic;">#, BLOCK# from v\$managed_standby</span>
        where process<span style="color: #339933;">=</span><span style="color: #ff0000;">'LGWR'</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$psequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fetchrow_array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">### query stdby</span>
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">select</span> SEQUENCE<span style="color: #666666; font-style: italic;">#, BLOCK# from v\$managed_standby</span>
        where process<span style="color: #339933;">=</span><span style="color: #ff0000;">'RFS'</span> <span style="color: #b1b100;">and</span> client_process<span style="color: #339933;">=</span><span style="color: #ff0000;">'LGWR'</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$ssequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$sblock</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fetchrow_array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;PROD   : %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$psequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;STANDBY: %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ssequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$sblock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">select</span> nvl<span style="color: #009900;">&#40;</span>sum<span style="color: #009900;">&#40;</span>blocks<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">+</span> <span style="color: #0000ff;">$pblock</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$sblock</span> as BLOCK_GAP
    from v<span style="color: #0000ff;">\$archived_log</span>
        where sequence<span style="color: #666666; font-style: italic;"># between $ssequence and $psequence</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$blockgap</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fetchrow_array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%-10d blocks gap<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$blockgap</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #339933;">;</span></pre></div></div>

<p>Any comment is appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Tips: Bash Prompt and Oracle</title>
		<link>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/</link>
		<comments>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 23:19:18 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[prompt]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=36</guid>
		<description><![CDATA[
export PS1=\u@\h:\w\$

I disagree with default bash prompt. Do you? It&#8217;s quote common to work with long paths:

ludovico@host:/u01/app/oracle/product/10.2.0/network/admin$ \
/nooo/this/command/line/is/really/long/and/offcourse -I \
-will -wrap -my -command -line

and, when working on multi-database environments I need to check my environment:

env &#124; grep -i oracle
#or
echo $ORACLE_SID
echo $ORACLE_HOME

I currently use this prompt, instead:

export PS1=$'\\n# [ $LOGNAME@\h:$PWD [\\t] [`ohvers` SID:${ORACLE_SID:-&#34;no sid&#34;}] ]\\n# '
&#160;
# [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=\u<span style="color: #000000; font-weight: bold;">@</span>\h:\<span style="color: #c20cb9; font-weight: bold;">w</span>\$</pre></div></div>

<p>I disagree with default bash prompt. Do you? It&#8217;s quote common to work with long paths:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ludovico<span style="color: #000000; font-weight: bold;">@</span>host:<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>product<span style="color: #000000; font-weight: bold;">/</span>10.2.0<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>admin$ \
<span style="color: #000000; font-weight: bold;">/</span>nooo<span style="color: #000000; font-weight: bold;">/</span>this<span style="color: #000000; font-weight: bold;">/</span>command<span style="color: #000000; font-weight: bold;">/</span>line<span style="color: #000000; font-weight: bold;">/</span>is<span style="color: #000000; font-weight: bold;">/</span>really<span style="color: #000000; font-weight: bold;">/</span>long<span style="color: #000000; font-weight: bold;">/</span>and<span style="color: #000000; font-weight: bold;">/</span>offcourse <span style="color: #660033;">-I</span> \
<span style="color: #660033;">-will</span> <span style="color: #660033;">-wrap</span> <span style="color: #660033;">-my</span> <span style="color: #660033;">-command</span> <span style="color: #660033;">-line</span></pre></div></div>

<p>and, when working on multi-database environments I need to check my environment:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> oracle
<span style="color: #666666; font-style: italic;">#or</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$ORACLE_SID</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$ORACLE_HOME</span></pre></div></div>

<p>I currently use this prompt, instead:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=$<span style="color: #ff0000;">'\\n# [ $LOGNAME@\h:$PWD [\\t] [`ohvers` SID:${ORACLE_SID:-&quot;no sid&quot;}] ]\\n# '</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># [ ludovico@caldara_2k:/u01/app/oracle/product/10.2.0/db_1/network/admin [23:15:58] [10.2.0 SID:orcl] ]</span>
<span style="color: #666666; font-style: italic;">#</span></pre></div></div>

<p>What is `<em>ohvers</em>`?? I defined this function to get the version of oracle from my ORACLE_HOME variable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ohvers <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$ORACLE_HOME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">'s/.*\/\([[:digit:].]\+\)\/.*/\1/p'</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Pros:</p>
<ul>
<li>I have a blank line that separate my prompt from previous output</li>
<li>I get the system clock (useful when saving my konsole history. Did I say konsole?)</li>
<li>I can see my Oracle Environment before launching dangerous commands</li>
<li>I have an empty line to start my endless commands</li>
<li>I have a lot of sharps &#8220;#&#8221; : they are fine against wrong copy&amp;paste operations&#8230;</li>
</ul>
<p>Suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle RAC Standard Edition to achieve low cost and high performance</title>
		<link>http://www.ludovicocaldara.net/dba/oracle-rac-standard-edition-to-achieve-low-cost-and-high-performance/</link>
		<comments>http://www.ludovicocaldara.net/dba/oracle-rac-standard-edition-to-achieve-low-cost-and-high-performance/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 23:43:04 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[RAC]]></category>
		<category><![CDATA[Standard Edition]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=29</guid>
		<description><![CDATA[I finished today to create a new production environment based on 2 Linux serverX86_64 and running Oracle RAC 10gR2. (I know, there is 11g right now, but I&#8217;m a conservative!)
Wheeew, I just spent a couple of hours applying all the recommended patches!
We choosed 2 nodes with a maximum of 2 multi-core processors each one so [...]]]></description>
			<content:encoded><![CDATA[<p>I finished today to create a new production environment based on 2 Linux serverX86_64 and running Oracle RAC 10gR2. (I know, there is 11g right now, but I&#8217;m a conservative!)<br />
Wheeew, I just spent a couple of hours applying all the recommended patches!<br />
We choosed 2 nodes with a maximum of 2 multi-core processors each one so we can license Standard Edition instead of Enterprise Edition. 64bits addressing allow us to allocate many gigabytes of SGA. I&#8217;m starting with 5Gb but I think we&#8217;ll need more. And a set of 6&#215;300Gb 15krpms disks (it can be expanded with more disks and more shelves).<br />
This configuration keeps low the total cost of ownership but achieves best performance.<br />
Due to disks layout, costs and needed usable storage, we had to configure one huge RAID5 on the SAN with multi-path. I decided anyway to create 2 ASM disk groups (ASM is mandatory for Standard Edition RAC), one for the DB, the second one for the recovery area. With spare disks we should have enough availability and even if it&#8217;s a RAID5 I saw good write performances (&gt;150M/s).</p>
<p>Welcome new RAC, I hope we&#8217;ll feel good together!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/oracle-rac-standard-edition-to-achieve-low-cost-and-high-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s time to trouble&#8230;</title>
		<link>http://www.ludovicocaldara.net/dba/its-time-to-trouble/</link>
		<comments>http://www.ludovicocaldara.net/dba/its-time-to-trouble/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 10:42:58 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=24</guid>
		<description><![CDATA[Sometimes it&#8217;s hard to find enough time to write something or even to only THINK about writing something&#8230;
The following are the projects I have to complete before the deadline of December 17th (at least if I still want to go on vacation&#8230;)

A totally new Oracle 10gR2 RAC SE on Linux (OCFS2, ASM) including jboss frontends, [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes <strong>it&#8217;s hard to find enough time to</strong> write something or even to only <strong>THINK about writing something</strong>&#8230;</p>
<p>The following are the projects I have to complete before the deadline of December 17th (at least if I still want to go on vacation&#8230;)</p>
<ul>
<li>A totally new <strong>Oracle 10gR2 RAC SE</strong> on Linux (<strong>OCFS2</strong>, <strong>ASM</strong>) including <strong>jboss</strong> frontends, backups, monitoring, documentation. (Servers are ready today).</li>
</ul>
<ul>
<li>A <strong>Disaster recovery</strong> architecture based on <strong>Dataguard</strong> with scripts based on rsync to do filesystem replication, with failover and failback, including backups, monitoring, documentation. (The server in DR site is reachable via network today).</li>
</ul>
<ul>
<li>A <strong>17 server</strong> infrastructure (among others a <strong>RAC 10gR2</strong> on linux) <strong>transfer</strong> from Milan datacenter to here. It&#8217;s planned for december 11th but I have to crosscheck backup and contingency requirements.</li>
</ul>
<ul>
<li>A <strong>14 serve</strong>r infrastructure (based on Windows and <strong>SqlServer</strong>) transfer from Milan datacenter to here. To be planned in december.</li>
</ul>
<ul>
<li>A totally new cold failover cluster based on linux with <strong>Oracle DBMS and E-business suite</strong> (Servers will be provided soon, I hope!).</li>
</ul>
<ul>
<li>A new standalone <strong>Windows Server 64bit</strong> to outstand the 32bit allocation bottleneck for a <strong>500Gb</strong> oracle database (Server will be provided not before december 10th).</li>
</ul>
<ul>
<li>Normally manage the day-by-day work, including replying to e-mails and answering the phone.</li>
</ul>
<p><strong>AARGH!!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/its-time-to-trouble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
