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
The intent of this blog is to share my work experience and spread some smart solutions on Linux to System Administrators. I'm hoping the solutions shared in this Blog would be helpful and come as a handy for Viewers. Brief about me: I have 18+ years work experience in System and Cloud Administration domain, primarily works on VMware Cloud Products (vSphere, vCloud Director, vRealize Automation, NSX Adv. Load Balancer, vROps).