Skip to main content

Script to Monitor Dataguard Log Gap

=> SQL to fetch the log gap



	
[oracle@hostname ~]$ cat /home/oracle/scripts/standby-lag.sql
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') WHEN,': DR is ' || trim(to_char(1440 * (sysdate - max (next_time)),99999.99) ||' minutes behind') LAG from v$archived_log where applied ='YES';
exit;
[oracle@hostname ~]$

    

=> Shell script to email log gap every 4 hours




	

[oracle@hostname ~]$ cat /home/oracle/scripts/standby-lag.sh
#!/bin/bash
##########################################################################################
#
# Purpose     : Script to email standby lag details
# Created on  : 
# Last Update :
#
##########################################################################################
echo -e "Please find the details below : "
echo -e " "
echo -e " "
echo -e "Script Started at `date`"
echo -e " "
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/u01/app/oracle/product/12.1.0.2/dbhome_1/bin:/home/oracle/.local/bin:/home/oracle/bin
export ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1
export LD_LIBRARY_PATH=/u01/app/oracle/product/12.1.0.2/dbhome_1/lib
export ORACLE_SID=PRODCDB
/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/sqlplus -s / as sysdba @/home/oracle/scripts/standby-lag.sql

echo -e " "
echo -e " "
echo -e "Script Ended at `date`"
echo -e " "
mailx -r "smtp_email@domain.com" -s "DR Sync Status" -S smtp="smtp.office365.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="smtp_email@domain.com" -S smtp-auth-password='smtp_email_password' -S ssl-verify=ignore -S nss-config-dir="/etc/pki/nssdb/" -c "to_user1_email@domain.com" "to_user2_email@domain.com" < /home/oracle/scripts/logs/standby-lag.log
exit;
[oracle@hostname ~]$ 


    


=> Schedule the script in crontab 



	

[oracle@hostname ~]$ crontab -l
00 */4 * * * /home/oracle/scripts/standby-lag.sh > /home/oracle/scripts/logs/standby-lag.log
[oracle@hostname ~]$


    




Comments

Popular posts from this blog

Data Safe - Introduction

Oracle Data Safe - Practical Guide Oracle Data Safe learner guide Oracle Data Safe Assess risk, discover sensitive data, audit activity, and mask safely It focuses on what Data Safe helps you do operationally: review security posture, find risky identities, centralize auditing, locate sensitive data, and produce safer non-production copies. Contents 01 Why Data Safe matters 02 Where it fits 03 Capability map 04 Assessments 05 Activity Auditing 06 Discovery and Masking 07 Operating model 08 First 30 days 09 Knowledge check Section 01 Why Data Safe matters Database security work is often fragmented. One process checks configuration drift, another stores audit logs, another team scans for PII, and another team writes masking logic for test refreshes. Data Safe is useful because it turns those separate jobs into one security workflow. Key idea The best way to think about Data Safe is as a control plane for database security posture: assess the target, identify risky accounts, d...

Testing Different Access Paths : Concatenated Index

Oracle Concatenated Indexes - Practical Deep Dive Oracle concatenated index deep dive Concatenated Indexes How composite indexes really work, why column order matters, and when skip scan changes the story Concatenated indexes, also called composite indexes, are easy to explain badly and surprisingly rich to explain well. The usual summary is “Oracle can use the index only when the leading column is present,” but that is only the starting point. To design them properly, you need to think about leading portions, equality versus range predicates, ordering requirements, skip scan eligibility, covering behavior, and whether one composite index can replace several single-column indexes in a given workload. Contents 01 What concatenated indexes are 02 Leading edge and leading portion 03 Why column order matters 04 Skip scan and when it helps 05 Access patterns and plan reading 06 Covering and sort elimination 07 Design rules that actually hold 08 Common mistakes 09 End-to-end demo 1...

Database Replay - Real Application Testing (RAT)

Oracle Database Replay and RAT - Practical Deep Dive Oracle Database Replay deep dive Database Replay and Real Application Testing How to validate upgrades, patches, migrations, and risky changes with real workload behavior Database Replay is one of the most practical risk-reduction tools in the Oracle DBA toolbox. Instead of trusting synthetic benchmarks, isolated SQL tests, or intuition, you capture a real production workload, restore a test system to the same logical starting point, replay that workload, and analyze whether performance, errors, timing, and transactional behavior still look safe. Contents 01 What RAT actually is 02 Why Database Replay matters 03 End-to-end workflow 04 Capture design and prerequisites 05 Preprocess, calibrate, replay 06 Reading the results well 07 Pitfalls and unreplayable work 08 Database Replay vs SPA 09 Practical playbooks 10 Knowledge check Section 01 What Real Application Testing actually is Real Application Testing, usually shortened...