Section 3.3. StatsView

   

3.3 StatsView

After his triumph with OraExplain, Alan Burlison went on to create yet another superb Perl/Tk application, StatsView, a program designed for use by both system administrators and Oracle DBAs using Unix systems. If you serve both functions at your site, we feel confident that you'll love StatsView too. Although StatsView is aimed clearly at Solaris, the program's Oracle-based monitoring is equally applicable to other Unix operating systems, so we thought we'd install it on Linux to see how far we could push it.

Like many of the best things in life, StatsView comes with a few challenges:

  • You have to preinstall the gnuplot command-driven plotting program, which itself relies on various C libraries, depending on how you configure it. The gnuplot program plots functions and data points in many different formats in either GIF or PNG image formats. See Figure 3-6 for a typical example.

  • You'll also need an extra Perl/Tk module containing cutting-edge widgets.

Figure 3-6. StatsView and some gathered tuning figures
figs/pdba_0306.gif

Although installing StatsView requires some special challenges, it comes with a silver lining . In the course of getting StatsView to work, you'll have installed some of the best Perl and C libraries around for performing graphical information plotting on both Unix and Win32. Here's where you start going beyond Perl Imperial Trooper rank and start heading towards Perl Sith Lord status!

The first thing we need to do for StatsView is to get hold of the extended Tk::GBARR Perl/Tk module and layer it over the standard Perl/Tk Unix distribution. We'll describe that task and the other installation procedures in the following sections.

3.3.1 Installing Tk::GBARR

Although the main Perl/Tk download may seem to possess virtually all of the screen widgets you could possibly need, after a while you may require more specialized options. Many packages on CPAN provide additional functionality; check under the main /Tk module directory on CPAN.

One of the most popular packages is Slaven Rezic's Tk::GBARR package, which contains many varied Perl/Tk widgets created by one of Perl/Tk's prime movers. Many of these widgets provide capabilities beyond those in standard Perl/Tk distributions. Most of the Tk::GBARR widgets, such as Tk::ProgressBar , do eventually become part of the standard distribution, but if you want to get ahead of the game, you can find Tk::GBARR at:

http://www.cpan.org/authors/id/SREZIC

Follow these installation instructions:

  1. Download and unpack the latest tarball from CPAN:

     $ gzip -d Tk-GBARR-2.05.tar.gz $ tar xvf Tk-GBARR-2.05.tar $ cd Tk-GBARR-2.05 
  2. Check for the latest notes, where to post potential errors, and so on, and then install the program in the usual manner. Once again, note that during the make test step you'll see lots of GUI examples popping up, albeit this time very briefly :

     $ vi README $ perl Makefile.PL $ make $ make test $ make install 
  3. Subject to our usual warnings that you must deal with any unlikely errors before going on, you can now consider Tk::GBARR to be installed, ready for use with StatsView.

3.3.2 Downloading StatsView

Get StatsView itself from the following location:

http://www.cpan.org/authors/id/ABURLISON

Unpack it according to the standard cavalry drill:

 $ gzip -d StatsView-1.4.tar.gz $ tar xvf StatsView-1.4.tar $ cd StatsView-1.4 
3.3.2.1 The need for PNG

When we installed StatsView, we faced something of a dilemma. Although StatsView assumes that gnuplot will use the GIF graphics file format, there are some reasons why you may prefer to use another format. GIF presents a problem because the Lempel Ziv Welch (LZW) algorithm that underlies the GIF format is patented (see the sidebar, "The LZW Patent Issue"). To avoid patent complications, many people prefer to use the freely available PNG [2] and JPEG [3] formats.

[2] You can find out much more about PNG (Portable Network Graphics) at the following page: http://www.libpng.org/pub/png.

[3] The Joint Photographic Experts Group designed this image standard, which is named for them. You can find out more at the following two sites: http://www.ijg.org/, and http://www.jpeg.org.

In fact, the PNG graphics format came about largely as a result of patent issues. Many people were interested in developing an alternative, freely available format that could be using in place of LZW. After an initial technical paper from Thomas Boutell describing a proposed format, a number of like-minded developers got together to work on the new format, culminating in Guy Eric Schalnat's creation of the libpng library.

To avoid patent issues ourselves , we'll load up the PNG library and its required compression companion, zlib , for use with gnuplot .

3.3.2.2 Installing zlib

Used by PNG to compress its graphics, zlib is an open data-compression library that has now been ported to virtually every kind of operating system. You can get hold of the latest zlib package, generally called zlib.tar.gz , from here:

http://www.gzip.org/zlib
http://www.zlib.org

Created originally for PNG, zlib is maintained by Jean-loup Gailly, the primary author of gzip (http://www.gzip.org), and gzip coauthor Mark Adler, the original author of Zip (http://www. info -zip.org/Zip.html). Unsurprisingly, zlib is the back-end engine of the gzip program, decoupled and morphed into an independent library for other open source projects requiring compression (i.e., virtually everything using the Internet). zlib thus contains the same lossless deflationary compression algorithms employed by both Zip and gzip , and as originally used in PKWARE [4] (http://www.pkware.com). (For some help with compression terminology, see the sidebar, Lossless versus Lossy, later in this chapter in the discussion of DBD::Chart .)

[4] PKWARE was founded in 1986 by Phil Katz, a pioneer of compression software, who developed the .zip file format in 1989. This inspired the Zip and GNU Zip ( gzip ) open source projects that use unpatented compression algorithms. These algorithms are an alternative to LZW, a patented algorithm used in the compress executables found with most proprietary Unix distributions. See the discussion in the sidebar, The LZW Patent Issue.

To install zlib , run through the following steps to configure the Makefile: [5]

[5] We install zlib and PNG automatically for Win32 later when we download ActivePerl's GD.pm module for use with DBD::Chart . This has the required binaries built in.

  1. Decompress the original zlib.tar.gz tarball. This should unpack into a directory with a version number, such as zlib-1.1.3 as follows :

     $ gzip -d zlib.tar.gz $ tar xvf zlib.tar $ cd zlib-1.1.3 $ vi README $ ./configure 

    Before compilation, make sure to read the Makefile to see whether you'd like to change any compile options:

     $ vi Makefile 
  2. Once you're happy with Makefile , move straight into a tested compilation:

     $ make test 

    You're trying to create an output response such as:

     ... inflate with dictionary: hello, hello!  *** zlib test OK ***  
  3. Now it's time to install:

     $ make install 

    This copies zlib.h to /usr/local/include , and the library archive libz.a to /usr/local/lib . zlib is now accessible to other bodies of code that rely upon it, such as PNG.

The LZW Patent Issue

Compression is the process that reduces the physical size of blocks of information. It is vital to storing and transmitting data, particularly graphics data and data being transferred over networks. A number of compression algorithms have been widely adopted. One of the most popular, the LZW (Lempel Ziv Welch) algorithm, is used in the GIF graphics file format, the Unix compress utility, and many other pieces of software.

LZW is named after its developers: Abraham Lempel and Jakob Ziv, who first proposed substitutional compression in 1977 and 1978, and Terry Welch who modified the LZ-78 variant to create the algorithm in 1984. Unisys acquired the patent on the compression algorithm that came to be known as LZW.

For many years , developers used the LZW algorithm freely. But on December 28, 1994 came an announcement by CompuServe that it would start trying to collect royalties on the use of the company's GIF graphics file format because of its underlying use of LZW. CompuServe and others had been under increasing pressure from Unisys, the LZW patent holder. With the popularization of the Web, use of GIF and other technologies using LZW were booming. Despite a lot of complaint and controversy among developers and users, Unisys' patent and licensing agreements held up. The company did compromise by not seeking fees on products using LZW that were delivered prior to 1995.

Ultimately, the LZW patent controversy led developers to seek out and develop their own compression algorithms and tools ” for example, PNG and zlib .

3.3.2.3 Installing PNG

You can get hold of the latest libpng tarball from the following pages:

http://www.libpng.org/pub/png

  1. We begin our dance with the usual introductions :

     $ gzip -d libpng-1.0.12.tar.gz $ tar xvf libpng-1.0.12.tar $ cd libpng-1.0.12 $ vi README INSTALL 
  2. You'll find all sorts of Makefile versions in the /scripts directory, for different Unix flavors. Choose your poison and copy it to the main download directory. Look it over carefully to ensure that it's right for your system:

     $ cp scripts/makefile.linux makefile $ vi makefile 
  3. Following the advice given within the file, we manually pointed the following variables at places matching our immediately previous installation of zlib :

     ZLIBLIB=/usr/local/lib ZLIBINC=/usr/local/include 

    Make sure you're also happy with the default installation file destinations:

     prefix=/usr/local INCPATH=$(prefix)/include LIBPATH=$(prefix)/lib 
  4. Let's make and test PNG:

     $ make test 

    Look for an output similar to the following:

     ...  tIME = 7 Jun 1996 17:58:08 +0000  libpng passes test  
  5. Also check to make sure that the two PNG files produced by this installation, pngtest.png and pngout.png , are identical. You can view this PNG image in Figure 3-7; the image is also borrowed by the Tk::PNG installation we'll be doing later for Perl/Tk.

  6. You'll find other assorted tests mentioned within the INSTALL file. Once you're happy with these, install PNG properly:

     $ make install 

    All of the necessary libraries and include files should now go to /usr/local/include and /usr/local/lib , as with zlib earlier.

Figure 3-7. PNG, JPEG, and gd test images
figs/pdba_0307.gif
3.3.2.4 Installing gnuplot

For all the latest information and downloads relating to gnuplot , check out:

http://www.gnuplot.info
http:// sourceforge .net/projects/gnuplot

For GIF usage, gnuplot uses an old version of gd , which itself is no longer available from Thomas Boutell's gd site. This is because gd now only deals with PNG and JPEG images, which is why we're avoiding the use of GIFs with gnuplot .

In the future, the gnuplot team may be forced, for patent reasons, to withdraw the old gd downloads they maintain. They recommend that you switch to using PNG as soon as you can; most of the latest browser technologies now support PNG. (We'll be installing the more modern PNG-based gd program later, when we install Lincoln Stein's GD.pm program for use with Perl/Tk.)

  1. Let's get straight into the installation game:

     $ gzip -d gnuplot-3.7.1.tar.gz $ tar xvf gnuplot-3.7.1.tar $ cd gnuplot-3.7.1 
  2. Next, we check out the 0README and 0INSTALL files:

     $ vi 0README 0INSTALL 
  3. Following their advice, we checked the term /png.trm file and found nothing problematic there. By default, the gnuplot compilation checks all the directories such as /usr/local/lib and /usr/local/include , where we'd installed our required PNG and zlib library files. We were able to configure without incident. Notice that we deliberately fail to include the old GIF-based gd program.

     $ ./configure  --without-gd  --with-png $ make 
  4. Optional tests are provided:

     $ cd demo $ ../gnuplot simple.dem 

    If the ../gnuplot simple.dem step fails to work first time, and you're running an X11 display, it may be because gnuplot requires the currently uninstalled gnuplot_x11 driver program. You may therefore have to update your PATH, unless you've previously installed an earlier gnuplot version:

     $ PATH=`pwd`/..:$PATH $ ../gnuplot simple.dem 

    (This test problem will resolve itself once you've fully installed gnuplot .)

  5. Once gnuplot is executing successfully, you can run several other sample programs too from the same directory:

     $ ../gnuplot fit.dem 
  6. Once you're happy with these demonstrations , install gnuplot under /usr/local/bin :

     $ make install 

    Now we can get back to the StatsView installation directory.

3.3.2.5 Installing StatsView

Now we're back to more mainstream Perl territory. After the final make install step, StatsView produces a program called sv , which is placed into the /usr/local/bin directory:

 $ cd .. $ perl Makefile.PL $ make $  make install  

Now we can test this initial Linux-PNG setup in the following way:

  1. First of all, the main /usr/local/bin/sv program uses a Solaris-based ps -ef command to check whether the Oracle background processes are running. This command was unavailable on our Linux system, so we moved to /scripts within the StatsView unload directory and copied the original sv program to a new one of our own, lin_sv .

     $ cd scripts $ cp sv lin_sv 

    We then edited this file to replace the ps -ef command with a ps aux one. You might like to try something similar on your own operating system, if you hit the same kind of OS-specific problem.

  2. Before testing the program, also make sure that your target database is running with an appropriate listener.

  3. Next, as the root user , create a statistical information storage directory:

     $ pwd $ mkdir StatsViewTest 
  4. Ensure that your environment is set correctly, especially PATH , to help DBD::Oracle and your own system pick up the sv and lin_sv programs:

     $ export ORACLE_HOME=/u01/app/oracle/product/8.1.5 $ export LD_LIBRARY_PATH=$ORACLE_HOME/lib  $ export PATH=.:/usr/local/bin:$PATH  
  5. Finally, we ran our slightly Linux-modified copy of the sv program:

     $ cd scripts $ ./lin_sv & 
  6. The first thing we did was set up a file for the monitor to store information in. We did this by clicking Monitor , then Start . On the resulting Output tab we selected an Interval of 10 seconds and a Samples rate of 60, and then pressed Browse to nominate a file in which to save the results (see Figure 3-8).

    Figure 3-8. Setting up the StatsView monitoring process
    figs/pdba_0308.gif
  7. We also chose all of these available monitoring options and then set the monitor going:

    Buffer Cache
    Datafile I/O
    Library Cache
    Tablespace I/O
    Data Dictionary Cache
    Dynamic Extension
    Shared Pool

After 10 minutes, the monitoring completed automatically. We then moved to the second stage of StatsView to graphically view the information collected:

  1. Drill down onto the menu option, File , then Open File... to choose the nominated storage file.

  2. Click down on whichever monitor option is of interest; we chose Datafile I/O . Now a gnuplot graph will appear (as in the earlier Figure 3-6).

   


Perl for Oracle DBAs
Perl for Oracle Dbas
ISBN: 0596002106
EAN: 2147483647
Year: 2002
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net