Tech Tips  
Home   Company   Solutions   Products   Sales   Services   Support
 
 
 
   How to Custom Health Check Oracle App servers


To properly load balance Oracle Applicaiton Servers, WebMux needs to check the health status of the Oracle database. Place the following Perl based CGI code on your servers, then enable the custom-health-check on WebMux. For Apache or IIS servers, the instruction is little different: To install under Linux or Windows/Apache:

  1. We assume that the Oracle client libraries (available from http://www.oracle.com/technology/tech/oci/) are already installed under directory ORADIR.
  2. Building and install the DBD::Oracle and Sys::SigAction Perl modules.
  3. Move the CGI script to the desired directory.
  4. If the Oracle client libraries are not in the default load path, configure Apache with the correct path, e g. by adding SetEnv LD_LIBRARY_PATH ORADIR to the appropriate section, and reload Apache.

--------------------------------------------------------------
To install under Windows/IIS:
  1. We assume that the Oracle client libraries (available from http://www.oracle.com/technology/tech/oci/) are already installed under directory ORADIR.
  2. Building and install the DBD::Oracle and Sys::SigAction Perl modules.
  3. Move the CGI script to the desired directory.
  4. If the Oracle client libraries are not in the default load path, configure IIS with the correct path, e g. by setting the LD_LIBRARY_PATH system variable to ORADIR as described in http://www.microsoft.com/technet/prodtechnol/ windows2000serv/technologies/iis/maintain/ optimize/autoadm2.mspx.
The CGI code following is written in Perl:

#!/usr/bin/perl -Tw

#########################################
# (c)Copyright 2006 CAI Networks, Inc.
# index.cgi: CGI page to show status of an Oracle instance
# $Id: index.cgi,v 1.2 2006/10/23 12:00:04 jason Exp $
#########################################

use strict;
use Sys::SigAction qw(set_sig_handler);
use DBI;

# N.B.: Oracle client libraries:
# remember to put "SetEnv LD_LIBRARY_PATH <oracle-client-lib-path>" in
# Apache config

my $timeout = 5;

my $server = 'host=localhost;sid=XE';
my $dsn = "dbi:Oracle:$server";
my $status = 'OK'; # OK status

my $rv;
eval {     # guard connect attempt with timeout alarm
  my $h = set_sig_handler('ALRM',sub {die "TIMEOUT\n"});
  alarm($timeout);
  $rv = DBI->connect($dsn,"test","test");
  alarm(0);
};
alarm(0);
if ($@ eq "TIMEOUT\n") { # connect timed out
  $status = 'TIMEOUT';
  print STDERR "TIMEOUT\n";
}
else { # connect didn't timeout
  unless ($rv) {
   my $code = 'ORA-' . $DBI::err;
   $status = $code + see http://$code.ora-code.com/;
   }
}

print <<EOS;
Content-Type: text/plain

$status
$server

EOS

 
 
 
Contact us   Jobs   Press   Privacy   Terms of use
 
 
Copyright © 1987- CAI Networks, Inc. Copyright © 1998-2000 Red Hill Networks, Inc. All rights reserved.