ORACLE DATAGUARD Monitoring Scripts

Source: Internet
Author: User
Tags prepare

Using Perl to monitor Oracle Dataguard scripts

#!/usr/bin/perluse strict;use warnings;use dbi;    # load the  DBI modulemy  $ZabbixServer  =  "192.168.3.24";my  $ZabbixPort    =   "10051";my  $HOSTNAME      =  "Ora2";my  $SenderCMD = "/usr/local/ Zabbix/bin/zabbix_sender ";my  $Primtns  = " Test_st ";my  $Stantns  = " test "; my $ key          =  "Oracled.DG.Status";my  $KEYContent 1           =  "OK";my  $KEYContent 2           =  "Failed";my  $LogVal                 = 3;my  $user    =  "Zabbix"; my  $passwd  =  "Zabbix";my  $Primseq  = 0;my  $Stanseq  = 0; $ENV {" Oracle_home "}= '/oracle/proDuct/11.2.0/db_1 '; # $ENV {path} .=  $ENV {path} .  ':/oracle/product/11.2.0/db_1/bin ';###  perform the connection using the oracle drivermy  $DBH  =   Dbi->connect (  dbi:oracle: $Primtns ", " $user ", " $passwd ", { printerror =>  0 } )   or die  "Can ' t connect to oracle database:  $DBI:: errstr\n ";my  $sth  =  $dbh->prepare (    " Select max (sequence#)  maxseq     from v\ $ARCHIVED _log      where  resetlogs_id= (       SELECT   RESETLOGS_ID   from v\ $DATABASE _incarnation       where status= ' current ')   " ), $sth->execute;## #while   ( my  @recs  =  $sth->fetchrow_array )  {     $primseq =  $recs [0];###}### now, disconnect from the database$dbh-> disconnect  or warn  "disconnection failed:  $DBI:: errstr\n"; $DBH  =   dbi->connect (  "dbi:oracle: $Stantns",  "$user",  "$passwd",  { printerror = > 0 } )   or die  "Can ' t connect to oracle database:   $DBI:: errstr\n "; $sth  =  $dbh->prepare (    " Select max (sequence#)  maxseq     from v\ $ARCHIVED _log      where  resetlogs_id= (       SELECT   RESETLOGS_ID   from v\ $DATABASE _incarnation       where status= ' current '         and applied= ' YES ')   $sth->execute;## #while   ( my   @recs  =  $sth-≫fetchrow_array )  {     $Stanseq  =  $recs [0];###}### now,  disconnect from the database$dbh->disconnect  or warn  "Disconnection  failed:  $DBI:: errstr\n "; if ($Primseq-$Stanseq >= $LogVal) {    system (" $ sendercmd -z  $ZabbixServer  -p  $ZabbixPort  -s  $HOSTNAME  -k  $KEY  -o   $KEYContent 2 >/dev/null 2>&1 ");    }else{         system ("$SenderCMD  -z  $ZabbixServer  -p  $ZabbixPort  -s   $HOSTNAME  -k  $KEY  -o  $KEYContent 1 >/dev/null 2>&1 ");} Exit



This article is from the "Days together with it" blog, so be sure to keep this source http://raugher.blog.51cto.com/3472678/1551506

ORACLE DATAGUARD Monitoring Scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.