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
  2. Need an href="https://www.photonconsole.com/">SMTP2Go alternative? Choose a powerful email delivery service with secure SMTP servers, flexible APIs, real-time tracking, and cost-effective plans that improve deliverability for startups, enterprises, and digital marketers.

    ReplyDelete
  3. Compare SMTP2Go alternative built for better email performance. Discover platforms with advanced SMTP services, marketing automation, API integrations, and superior deliverability to optimize your business communication strategy.

    ReplyDelete

Post a Comment

Popular posts from this blog