Quick Dirty Script for Checking Oracle Data Gurad Gap and Emailing it

 Situation:


primary DB: prd_CCC

standby DB: prd_WWW


file 1: gap-check.bat

@echo off

cls

echo.

echo.

echo This script checks for Archive Logs at prd_ccc and Applied Logs at prd_www

echo.

echo Querying prd_ccc (Primary)

echo select max(sequence#) "Primary" from v$archived_log where archived='YES';|sqlplus -s / as sysdba

echo Querying prd_www (Standby)

echo select max(sequence#) "Standby" from v$archived_log where applied='YES';|sqlplus -s / as sysdba

echo.

DGMGRL / "show configuration"

date /t && time /t && hostname && whoami


file 2: emailer.ps1


$Username      = "username"

$EmailPassword = "password"

$today = Get-Date

$Username = $Username

$EmailTo = "adam@jasabyte.com" 

$EmailFrom = "server@jasabyte.com"

$Body = Get-Content .\status.log -Raw

$Subject = "PRIMARY/STANDBY DB GAP - $today"

$SMTPServer = "mail.smtp2go.com" 

$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom, $EmailTo, $Subject, $Body)

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) 

$SMTPClient.EnableSsl = $true 

$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $EmailPassword); 

$SMTPClient.Send($SMTPMessage)


Schedule file 1 and makes sure to make it pipe output > status.log and file 2 In sequence.
Actually, you can merge the two files also.. but am lazy.

//alak

Comments

Popular posts from this blog

SAP Backdoors {placeholder Post]

Oracle Trigger to Log Logon Denied ORA-1017 Error into Alert Log

SAP Fiori Launchpad Activation via Task List (STC01)