扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
使用perl来监控ORACLE DATAGUARD脚本
成都创新互联-专业网站定制、快速模板网站建设、高性价比肇东网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式肇东网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖肇东地区。费用合理售后完善,10年实体公司更值得信赖。#!/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;另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流