Monday, May 14, 2012

Perl subroutine to check Database Status

sub CheckDBStatus($)
{
my $host = $_[0];
my $dbStatus=`ssh $host -C "ps -ef | grep ora_pmon | grep -v grep -c"`;
if ($dbStatus == 1)
{
Log("Database is up on $host",0,LOGFILE);
return("0");
}
else
{
Log("Database is down on $host",0,LOGFILE);
return("1");
}
}

Note: You can use appropriate string to capture Oracle process with grep command.

No comments:

Post a Comment

Popular Posts

About Me

My photo
I have started this blog to share my work experience and spread some smart solutions on Linux to Internet community. I'm hoping more people will get benefited from this blog. Brief about me: I have 14+ years experience working as System Admin and currently work with VMware.