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

  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.

    ReplyDelete

Post a Comment

Popular posts from this blog

SAP: Segregate Different SMTP Mail Server Based on Sender Domain

SAP Client Copy Error: Errors occurred during export of container object FINB-TR-DERIVATION