Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Perl script to verify DB is up.

Re: Perl script to verify DB is up.

From: Rachel Carmichael <carmichr_at_hotmail.com>
Date: Wed, 21 Jun 2000 18:58:57 GMT
Message-Id: <10535.110052@fatcity.com>


Jared,

Um, you mean you have to include the PASSWORD on the command line???????

Rachel

>From: Jared Still <jkstill_at_bcbso.com>
>Reply-To: ORACLE-L_at_fatcity.com
>To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
>Subject: Re: Perl script to verify DB is up.
>Date: Wed, 21 Jun 2000 09:44:00 -0800
>
>On Wed, 21 Jun 2000, Mabry, Jennifer wrote:
>
> > Hello all,
> >
> > I and my group are pretty new DBA's and have a question for you all.
> >
> > Do any of you have a UNIX Perl script that monitors each of your
>instances
> > to verify the DB is up? If not, pages you?
> >
>
>Here's a basic connect script.
>
>The paging would be fairly easy to add by
>using a Perl Sendmail module.
>
>
>Jared Still
>Certified Oracle DBA and Part Time Perl Evangelist ;-)
>Regence BlueCross BlueShield of Oregon
>jkstill_at_bcbso.com - Work - preferred address
>jkstill_at_teleport.com - private
>
>--------------
>
>#!/usr/bin/perl
>
>use DBI;
>use strict;
>no strict 'vars';
>
>use Getopt::Long;
>
>my %optctl = ();
>
>Getopt::Long::GetOptions(\%optctl,
>"database:s","username:s","password:s","z","h","help");
>
>#setup environment - homegrown package
>
>my($db, $username, $password);
>
>if ( ! defined($optctl{database}) ) {
> Usage();
> die "database required\n";
>}
>$db=$optctl{database};
>
>if ( ! defined($optctl{username}) ) {
> Usage();
> die "username required\n";
>}
>$username=$optctl{username};
>
>if ( ! defined($optctl{password}) ) {
> Usage();
> die "password required\n";
>}
>$password=$optctl{password};
>
>#print "USERNAME: $username\n";
>#print "DATABASE: $db\n";
>#print "PASSWORD: $password\n";
>#exit;
>
># setup your Oracle environment before running this
># or ( less optimal ) set it up here
># $ENV{ORACLE_SID}='my_sid';
># $ENV{ORACLE_HOME}='/obase/product/8.1.5';
># $ENV{TNS_ADMIN}='/obase/product/8.1.5/network/admin/';
>
>$dbh = DBI->connect('dbi:Oracle:' . $db, $username, $password, { RaiseError
>=> 1, AutoCommit => 0 } );
>
>die "Connect to $db failed \n" unless $dbh;
>
>$MySql="select \* from dual";
>
>$sth = $dbh->prepare($MySql);
>
>my $rv = $sth->execute;
>
>while( $ary = $sth->fetchrow_arrayref ) {
> print "\t\t$${ary[0]}\n";
>}
>
>$sth->finish;
>$dbh->disconnect;
>
>sub Usage {
> print "\n";
> print "usage: connect.pl\n";
> print " connect.pl -database dv07 -username scott -password tiger\n";
> print "\n";
>}
>
>
>
>
>--
>Author: Jared Still
> INET: jkstill_at_bcbso.com
>
>Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
>San Diego, California -- Public Internet access / Mailing Lists
>--------------------------------------------------------------------
>To REMOVE yourself from this mailing list, send an E-Mail message
>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from). You may
>also send the HELP command for other information (like subscribing).


Received on Wed Jun 21 2000 - 13:58:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US