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: <amerar_at_iwc.net>
Date: 28 Aug 2006 09:54:21 -0700
Message-ID: <1156784061.369927.239540@i42g2000cwa.googlegroups.com>

David Newman wrote:
> "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";
> }

Would be great, but this place does not have DBD/DBI and they do not want to install it.....go figure??!?!!? Received on Mon Aug 28 2006 - 11:54:21 CDT

Original text of this message

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