@echo off
setlocal enabledelayedexpansion
set "urls_file=urls.txt"
set "username=your_username"
set "password=your_password"
set "edge_path=%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe"
:: Loop through each URL
for /f "usebackq delims=" %%u in ("%urls_file%") do (
set "url=%%u"
:: Launch Edge with URL
start "" "%edge_path%" --new-window "!url!"
:: Wait for page to load (adjust delay as needed)
timeout /t 7 >nul
:: Send credentials using PowerShell
powershell -command "$wshell = New-Object -ComObject wscript.shell; $wshell.AppActivate('Microsoft Edge'); Start-Sleep -Milliseconds 800; $wshell.SendKeys('{TAB}'); $wshell.SendKeys('%username%'); $wshell.SendKeys('{TAB}'); $wshell.SendKeys('%password%'); $wshell.SendKeys('~')"
:: Wait for login to process
timeout /t 5 >nul
:: Close Edge window (Alt+F4)
powershell -command "$wshell = New-Object -ComObject wscript.shell; $wshell.AppActivate('Microsoft Edge'); $wshell.SendKeys('%%{F4}')"
:: Add delay before next URL
timeout /t 2 >nul
)
##
#!/bin/bash
# Database Connection Parameters
DB_USER="sysman"
DB_PASS="your_password"
DB_HOST="rac-host.example.com"
DB_SERVICE="your_service"
SYSDBA="as sysdba"
# Email Parameters
EMAIL_TO="dba@example.com"
EMAIL_SUBJECT="Oracle RAC Health Check Report"
# Output File
OUTPUT_FILE="/tmp/rac_health_report.html"
# Function to run SQL query and format HTML
run_query() {
sqlplus -s /nolog << EOF | awk 'BEGIN{print "
"} {print "" $0 " |
"} END{print "
"}' | sed 's/|/\<\/td\>\
/g'
connect $DB_USER/$DB_PASS@$DB_HOST/$DB_SERVICE $SYSDBA
set pagesize 50000
set linesize 1000
set heading off
set feedback off
$1
exit
EOF
}
# Start HTML Report
cat > $OUTPUT_FILE << EOF
Oracle RAC Health Check Report
Oracle RAC Health Check Report
Generated: $(date)
EOF
# 1. All Instance/DB Status
echo "1. Database/Instance Status" >> $OUTPUT_FILE
run_query "SELECT INST_ID, INSTANCE_NAME, HOST_NAME, STATUS, DATABASE_STATUS FROM GV\$INSTANCE;" >> $OUTPUT_FILE
# 2. Long Running Sessions
echo "2. Long Running Sessions (> 1 hour)" >> $OUTPUT_FILE
run_query "SELECT INST_ID, SID, SERIAL#, USERNAME, SQL_ID, ROUND((SYSDATE - SQL_EXEC_START)*24,2) HOURS, STATUS FROM GV\$SESSION WHERE (SYSDATE - SQL_EXEC_START)*24 > 1;" >> $OUTPUT_FILE
# 3. DB Blocking
echo "3. Database Blocking Sessions" >> $OUTPUT_FILE
run_query "SELECT blocker.INST_ID, blocker.SID, blocker_user.username blocker_user, waiter.INST_ID, waiter.SID, waiter_user.username waiter_user FROM GV\$LOCK blocker JOIN GV\$LOCK waiter ON (blocker.ID1 = waiter.ID1 AND blocker.ID2 = waiter.ID2) JOIN GV\$SESSION blocker_user ON (blocker.SID = blocker_user.SID) JOIN GV\$SESSION waiter_user ON (waiter.SID = waiter_user.SID) WHERE blocker.BLOCK > 0 AND waiter.REQUEST > 0;" >> $OUTPUT_FILE
# 4. DB Locking
echo "4. Database Locking" >> $OUTPUT_FILE
run_query "SELECT INST_ID, SID, TYPE, LMODE, REQUEST, CTIME FROM GV\$LOCK WHERE TYPE NOT IN ('MR','AE');" >> $OUTPUT_FILE
# 5. DB Load Last 1 Hour
echo "5. Database Load (Last 1 Hour)" >> $OUTPUT_FILE
run_query "SELECT BEGIN_TIME, END_TIME, AVG(CPU) CPU_AVG, AVG(IO) IO_AVG FROM GV\$SYSMETRIC_HISTORY WHERE GROUP_ID = 2 AND INTSIZE_CSEC < (60 * 100 * 60) GROUP BY BEGIN_TIME, END_TIME ORDER BY BEGIN_TIME DESC FETCH FIRST 12 ROWS ONLY;" >> $OUTPUT_FILE
# 6. DB Load Last 5 Minutes
echo "6. Database Load (Last 5 Minutes)" >> $OUTPUT_FILE
run_query "SELECT BEGIN_TIME, END_TIME, CPU, IO FROM GV\$SYSMETRIC WHERE GROUP_ID = 2 ORDER BY BEGIN_TIME DESC FETCH FIRST 1 ROW ONLY;" >> $OUTPUT_FILE
# 7. DB Parallel
echo "7. Database Parallel Processes" >> $OUTPUT_FILE
run_query "SELECT INST_ID, COUNT(*) PARALLEL_PROCS FROM GV\$PX_PROCESS GROUP BY INST_ID;" >> $OUTPUT_FILE
# 8. Invalid Objects
echo "8. Invalid Objects" >> $OUTPUT_FILE
run_query "SELECT OWNER, OBJECT_TYPE, COUNT(*) FROM DBA_OBJECTS WHERE STATUS != 'VALID' GROUP BY OWNER, OBJECT_TYPE;" >> $OUTPUT_FILE
# 9. Session Failure
echo "9. Session Failures" >> $OUTPUT_FILE
run_query "SELECT INST_ID, COUNT(*) FROM GV\$SESSION WHERE FAILOVER_TYPE IS NOT NULL AND FAILED_OVER = 'YES' GROUP BY INST_ID;" >> $OUTPUT_FILE
# 10. Active Session Count
echo "10. Active Session Count" >> $OUTPUT_FILE
run_query "SELECT INST_ID, COUNT(*) ACTIVE_SESSIONS FROM GV\$SESSION WHERE STATUS = 'ACTIVE' GROUP BY INST_ID;" >> $OUTPUT_FILE
# 11. All Database Service Info
echo "11. Database Services" >> $OUTPUT_FILE
run_query "SELECT INST_ID, NAME, NETWORK_NAME, CREATED, GOAL, ENABLED FROM GV\$SERVICES;" >> $OUTPUT_FILE
# 12. All ORA-Errors
echo "12. Recent ORA-Errors" >> $OUTPUT_FILE
run_query "SELECT ORIGINATING_TIMESTAMP, MESSAGE_TEXT FROM GV\$DIAG_ALERT_EXT WHERE MESSAGE_TEXT LIKE 'ORA-%' AND ORIGINATING_TIMESTAMP > SYSDATE - 1/24;" >> $OUTPUT_FILE
# Close HTML
echo "" >> $OUTPUT_FILE
# Send Email
mailx -a "$OUTPUT_FILE" -s "$EMAIL_SUBJECT" -S content-type=text/html "$EMAIL_TO" < /dev/null
# Cleanup
rm -f $OUTPUT_FILE
|