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


primary DB: prd_CCC

standby DB: prd_WWW

file 1: gap-check.bat

@echo off




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


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


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); 


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.



  1. Amazing article. I love how you talked about the trouble https://eiliana.com/technology/hire-wordpress-developers face when finding the right platform for freelance work. I also know about one freelancing platform that is Eiliana.com. It is a new and great platform for technical experts. They have some amazing strategies for hiring developers, and you should connect with them.


Post a Comment

Popular posts from this blog

SAP Backdoors {placeholder Post]

Fiori Apps Keep Calling Internal Hostname / Internal FQDN