In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Use 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 $KEYContent1 = "OK"; my $KEYContent2 = "Failed" My $LogVal = 3X my $user = "zabbix"; my $passwd = "zabbix"; my $Primseq = 0 X my $Stanseq = 0 X 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 $KEYContent2 > / dev/null 2 > & 1") } else {system ("$SenderCMD-z $ZabbixServer-p $ZabbixPort-s $HOSTNAME-k $KEY-o $KEYContent1 > / dev/null 2 > & 1");} exit
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.