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

Home -> Community -> Usenet -> c.d.o.server -> Re: Is Database Up?

Re: Is Database Up?

From: David Newman <dnewman_at_maraudingpirates.org>
Date: 28 Aug 2006 12:49:39 -0400
Message-ID: <f6wpsekiz4s.fsf@BOS004777.na.pxl.int>


"amerar_at_iwc.net" <amerar_at_iwc.net> writes:

> jbmo..._at_gmail.com wrote:
>
> Thanks for the tip, but I was hoping for some simple command in Unix
> that I can run and pipe the results or status code into a
> variable.........something similar to:
>
> row_count=`ps -ef | grep ora_smon_$ORACLE_SID | fgrep -v 'grep' | wc
> -l`
>
> But, it would have to be for a remote database...........

I tend to use perl for this kind of thing. You can work with Oracle programmatically but it's still scripting.

Regards
-Dave N.

#!/usr/bin/perl
use strict;
use DBI;

my $host='db001';
my $service_name='ORCL.ORACLE.COM';
my $user='tonytester';
my $passwd='yo';
my $port='1542';
my $dsn="dbi:Oracle:host=$host;port=$port;service_name=$service_name";

my $dbh = DBI->connect($dsn, $user, $passwd) or die( 'Failed to connect' );

my $sth = $dbh->prepare('SELECT status FROM v$instance') or die( "Failed to prepare" );

$sth->execute()
or die( "Failed to execute" );

my @row = $sth->fetchrow_array;
if ($row[0] ne "OPEN") {
  # You've got a problem
} else {
  print "Database is open\n";
} Received on Mon Aug 28 2006 - 11:49:39 CDT

Original text of this message

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