4.3 KarmaSean Hull's Karma program takes Oracle database monitoring a step further. Like Oracletool, it is intended to help DBAs with their daily work. The program is especially helpful in automating the tracking of important, though tedious-to-collect information — information that you may need to know, but be too busy to gather personally. Karma's comprehensive configuration capabilities let you select the particular features and database events to monitor, how often to monitor them, and how strictly to monitor them. (See Figure 4-8 for a sample screen produced by Karma.) You can also break up your many databases into groups, each with its own monitoring criteria and thresholds. Karma's goal is to help Oracle DBAs collect numerous useful statistics automatically in the background. Karma offers the ability to notify the DBA by email when database problems occur, and it provides a single place to keep track of many different databases. Figure 4-8. The main Karma page indicating alarmsBecause Karma collects a wider range of statistics than Oracletool's monitoring features do, and because it provides a full suite of online monitoring options, program installation and configuration are slightly more involved. Unlike Oracletool, Karma is not implemented as a CGI script. Instead, it runs a daemon, generating HTML pages in a specified location. For complete information about Karma, go to: The following sections describe the installation on both Unix and Win32. In both environments, note that you may also need several other modules, depending on your requirements:
4.3.1 Installing Karma on UnixWe downloaded the following file from the Karma site provided earlier: For Unix, follow these instructions:
4.3.1.1 Installing TermReadKey.pmIf you will later want to check the alert log file for each database via Karma, you need to install the TermReadKey.pm module to keep passwords secret. It provides Perl with various input controls for reading console input and allowing specialized input, such as reading in passwords without echoing them back. Follow these steps:
4.3.1.2 Installing MailTools.pmIf you're thinking of using Karma's automatic email options, you'll need to install MailTools.pm. To do this, you also need Graham Barr's libnet library. We're after two Perl modules contained within this bundle, Net::SMTP and Net::Domain. The full libnet module collection is summarized in Table 4-3.
You can get hold of the latest bundle, such as libnet-1.0704.tar.gz, from: Once you've unpacked the tarball, the perl Makefile.PL step does more configuration than most Perl module construction kits, and the test step also requires access to a list of Internet hosts. Be prepared to answer plenty of questions, especially during the installation stage. You can, however, skip these tests if you wish: $ perl Makefile.PL
$ make
$ make test
$ make install
We're now ready for MailTools.pm proper: $ gzip -d MailTools-1.40.tar.gz $ tar xvf MailTools-1.40.tar $ cd MailTools-1.40 $ perl Makefile.PL $ make $ make test $ make install 4.3.1.3 Configuring KarmaTo test Karma and create errors (which we're hoping the program will email us about), we created a ridiculously small TEMP temporary tablespace: CREATE TABLESPACE TEMP DATAFILE '/u04/temp1orcl.ora' SIZE 10240 REUSE AUTOEXTEND OFF DEFAULT STORAGE ( INITIAL 4096 NEXT 2048 PCTINCREASE 0 ) TEMPORARY LOGGING ; Because we're intending to use OS monitoring, we now need our own special user located directly within the target database, with a SELECT ANY TABLE privilege. We also need a small set of statistical collection tables. We can accomplish this by running two scripts provided by Karma, in the ../sql directory:
Running these two SQL scripts produces the following output, including the expected truncation error: SQL> @karma_user Enter value for karma_password: seadevil User created. Grant succeeded. Grant succeeded. SQL> connect karma/seadevil Connected. SQL> @karma_objs Creating karma_os_stats table... Table created. Creating karma_alertlog_errors table... Table created. TRUNCATE TABLE karma_agent * ERROR at line 1: ORA-00942: table or view does not exist Creating karma_agent table... Table created. 1 row created. SQL> Follow these steps:
Checking on this later via the web browser, we'll also be able to find out something about our TEMP tablespace, with the information generated from our alert log file (see Figure 4-9). Figure 4-9. Karma reporting on alert log errors4.3.2 Installing Karma on Win32At the time this book went to press, the full daemon karmagentd functionality of Karma had yet to be ported to a Win32 service. Even now, though, you can still do a lot with karmad:
4.3.2.1 Configuring Karma on Win32The karma.conf file itself contains plenty of help on how to configure Karma, though fortunately most of the configuration is fairly intuitive. The main configuration parameters we chose were: karma:Henley-On-Thames:ORCL:karma:dalek repqueue reperror Henley-On-Thames:refresh:5:75 Henley-On-Thames:redolog:1:30:15 Henley-On-Thames:rollback:1:0:0 Henley-On-Thames:tablespace:1:85:95 Henley-On-Thames:slowsql:1:100:200 Henley-On-Thames:alertlog:1:60:86400 Henley-On-Thames:hitratios:1:95:70 Henley-On-Thames:fragmentation:1:0:0 Henley-On-Thames:extents:1:2:1 Henley-On-Thames:latch:1:0:0 Henley-On-Thames:mts:1:50:75 Henley-On-Thames:os:1:5:10 warn_blink:false alert_blink:false pref_group_sections:true #doc_root: Commented out to use default Present Working Directory The database connection line at the top of the list is perhaps the most important thing to get right. We also decided to default the ..\doc_root to the present working directory. 4.3.2.2 Running Karma on Win32To get the basic karmad program running, change to the main Karma home directory, make sure your target Oracle database is accessible via its listener, and then run the main Karma monitor program: C:\> cd C:\Program Files\Apache Group\Apache\htdocs\karma-1.0.0 C:\> perl bin\karmad -c karma.conf The daemonic karmad monitor periodically produces a series of HTML pages, which you can access via a web server (you can also access them directly with a local browser if you'd prefer). We liked the idea of the first option, so we started up Apache and then visited the following page:
You can see the first result in Figure 4-10. Figure 4-10. The main Karma screen on Win324.3.2.3 Extra Perl modules for Win32If you do want to push Karma to get mail notification and OS monitoring, you'll need to get hold of two more ActivePerl packages. Connect to the Internet and run ActivePerl's PPM program to install the MailTools package. You may also want to install TermReadKey in anticipation of the time that the daemon-based karmagentd will be ported to a service under Win32: C:\> ppm PPM> install MailTools PPM> install TermReadKey PPM> exit |