Oracle capacity planning with RRDTOOL

RRDize everything, chapter 2

Oracle Database Server has the most powerful system catalog that allows to query almost any aspect inside an oracle instance.
You can query many v$ fixed views at regular intervals and populate many RRD files through rrdtool: space usage, wait events. system statistics and so on…

Since release 10.1 Oracle has introduced Automatic Workload Repository, a finer version of old good Statspack.
No matter if you are using AWR or statspack, you can rely on their views to collect data for your RRDs.

If you are administering a new instance and you haven’t collected its statistics so far, you can query (as example) the DBA_HIST_BG_EVENT_SUMMARY view to gather all AWR data about wait events. Historical views could be useful also to collect historical data once a week rather than query the fixed views every few minutes doing the hard work twice (you and AWR).

The whole process of gathering performance data and update rrd files can be resumed into the following steps:

– connect to the database
– query the AWR’s views
– build and execute an rrdtool update command
– check if rrd file exists or create it
– update the rrd file

The less rrdtool update commands you will execute, the better the whole process will perform.
Do it in a language you are comfortable with and that supports easily connection descriptors.

Since I’m very comfortable with php, I did it this way.

This is a very basilar script that works greatly for me with good performances:

Depending on how many different wait events you have, you’ll have a certain number of rrd files:

As you can see, they are not so big…

Once you have your data in rrd files, it’s quite simple to script even complex plots with several datasources. Everything depends on the results you want.
This script stack all my wait events for a certain instance: it takes the directory containing all the rrds as first argument and the number of hours we want to be plotted as second argument:

The resulting command is very long:

This is the resulting graph:
Graph plotted with rrdtool displaying Oracle instance Wait Events


Any comment is appreciated! thanks

The following two tabs change content below.


Oracle ACE Director and Principal Consultant at Trivadis
Ludovico is an Oracle ACE Director, frequent speaker and community contributor, working as Principal Consultant for Trivadis, the leading Oracle consulting firm in Switzerland and German-speaking Europe.

2 thoughts on “Oracle capacity planning with RRDTOOL

  1. #!/bin/bash

    # here is porting to bash – i like the idea .

    set -o nounset
    set -o errexit

    # global vars
    mysql=”sqlplus -s -l ”

    function docmd()
    [ “$1” = “” ] && return 0
    echo “$1\n.”
    eval “$1″
    return $?

    function createRRD() {
    local name=$1
    local interval=$2
    local cs=$3
    local hb=$((interval*5)); #heartbeat
    local cmd=”$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”
    docmd “$cmd” || return $?
    return 0;

    #/* take the snapshot frequency from dba_hist_wr_control to create the RDD with correct heartbeat value */
    sql=”select extract(hour from snap_interval)*3600 + extract(minute from snap_interval)*60 as SEED from DBA_HIST_WR_CONTROL”
    interval= ${mysql} ${connstr}<$outfile<100000
    and s.instance_number=i.instance_number
    and s.instance_number=g.instance_number)
    order by event_name, END_INTERVAL_TIME;

    cat $outfile | while IFS=, read end_interval_time event_name wait_class total_waits ms; do
    if [ "$oldevent" != "$event_name" ]; then
    [ ! "$i" -eq "0" -a "$cmd" != "" ] && docmd "$cmd"
    echo event=$event_name
    cleanName=${event_name// /_}
    # if there is no rrd for this event, I create a new one
    [ ! -f "${WD}/${cleanName}.rrd" ] && createRRD "$cleanName" "$interval" ""
    # * I initialize a new update command. This string act as a buffer: I append many values to be updated so I'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="$rrd update $WD/${cleanName}.rrd"
    $rrd info $WD/${cleanName}.rrd| grep last_update | awk ‘{print \$NF}’`
    printf “%s – %s – last: %d\n” “$event_name” “$cleanName” “$last”
    # //print “time: “.$time.” last: “.$last.”\n”;
    if [ “$time” -gt “$last” ]; then
    cmd=”$cmd ${time}:${total_waits}:${ms}”
    if [ “$i” -gt “40” ]; then
    # // when I reach 40 values per commandline I force
    # // the update: next loop will reinitialize a new commandline.
    docmd “$cmd”
    [ “$i” -eq “0” ] || docmd $cmd

    [ -f “$outfile” ] && rm “$outfile”
    echo done in $SECONDS

  2. Pingback: http://%/bvwkjea

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.