使用perl來(lái)監(jiān)控ORACLE DATAGUARD腳本
成都創(chuàng)新互聯(lián)-專(zhuān)業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性?xún)r(jià)比肇東網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式肇東網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋肇東地區(qū)。費(fèi)用合理售后完善,10年實(shí)體公司更值得信賴(lài)。#!/usr/bin/perl use strict; use warnings; use DBI; # Load the DBI module my $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 $KEYContent1 = "OK"; my $KEYContent2 = "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 driver my $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 $KEYContent2 >/dev/null 2>&1"); }else{ system("$SenderCMD -z $ZabbixServer -p $ZabbixPort -s $HOSTNAME -k $KEY -o $KEYContent1 >/dev/null 2>&1"); } exit;另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。