Oracle EBS OS Patching – Smart Mount Point Checker with Email Alert
Automatically detects missing mount points after server reboot
Author: Abdul Muqeet
Date:
Problem during OS Patching
During OS patching, servers are rebooted by OS admins. After reboot, some critical filesystems (e.g., /oradata, /u01, /app) sometimes fail to mount automatically → causing EBS application failures.
Solution
A single script that:
- First run (before reboot): Captures current mount points
- Second run (after reboot): Compares & sends HTML email if anything is missing
Final Script (with auto-email)
#!/bin/bash
# File: check_missing_mounts_with_email.sh
# Author: Abdul Muqeet
# Purpose: 1st run → Save snapshot | 2nd run → Compare + Send HTML email
# ------------------- Config (Modify only these) -------------------
EMAIL_TO=" patch-team@gmail.com"
SNAPSHOT_DIR="$HOME/patch_mount_snapshots"
mkdir -p "$SNAPSHOT_DIR"
HOST=$(hostname | tr '[:upper:]' '[:lower:]' | sed 's/\..*//')
SNAPSHOT_FILE="$SNAPSHOT_DIR/${HOST}_pre_patch_mounts_$(date +%Y%m%d_%H%M%S).snapshot"
REPORT_FILE="/tmp/mount_report_$$.html"
DATE=$(date '+%Y-%m-%d %H:%M:%S')
get_real_mounts() {
df -hP 2>/dev/null | tail -n +2 | awk '{print $6}' | \
grep -vE '^(/dev|/proc|/sys|/run|/tmp|/boot|/$|/var/tmp|/var/run|/home|/scratch)'
}
# Start HTML report
cat > "$REPORT_FILE" </dev/null 2>&1; then
get_real_mounts | sort > "$SNAPSHOT_FILE"
echo "<tr><td class=\"patch\">PRE-REBOOT SNAPSHOT</td><td>Snapshot created: $SNAPSHOT_FILE<br><br>$(cat "$SNAPSHOT_FILE" | sed 's/^/• /')</td></tr>" >> "$REPORT_FILE"
echo "</table><p>Reboot in progress... Run again after server is up.</p></body></html>" >> "$REPORT_FILE"
(echo "To: $EMAIL_TO"; echo "Subject: [PRE-PATCH] Mount Snapshot - $(hostname)"; echo "Content-Type: text/html"; echo; cat "$REPORT_FILE") | /usr/sbin/sendmail -t
echo "Snapshot saved + email sent."
rm -f "$REPORT_FILE"
exit 0
fi
# Second run: Compare & email
LATEST_SNAPSHOT=$(ls -t "$SNAPSHOT_DIR/${HOST}"_pre_patch_mounts_*.snapshot* | head -1)
current_mounts=$(get_real_mounts | sort)
missing=$(comm -23 "$LATEST_SNAPSHOT" <(echo "$current_mounts"))
if [ -n "$missing" ]; then
findings="<b><span class=\"failed\">MISSING MOUNT POINTS!</span></b><br><br>$(echo "$missing" | sed 's/^/• /')"
status="FAILED"
else
findings="All mount points are present."
status="SUCCESS"
fi
echo "<tr><td class=\"patch\">POST-REBOOT CHECK</td><td>$findings</td></tr>" >> "$REPORT_FILE"
echo "</table><p>Current mounts:<br><pre>$(df -h | grep -vE '(tmpfs|devtmpfs)')</pre></p></body></html>" >> "$REPORT_FILE"
(echo "To: $EMAIL_TO"; echo "Subject: [POST-PATCH] Mount Check - $(hostname) [$status]"; echo "Content-Type: text/html"; echo; cat "$REPORT_FILE") | /usr/sbin/sendmail -t
echo "Report emailed. Status: $status"
read -p "Delete snapshot now? (y/N): " ans
[[ "$ans" =~ ^[Yy]$ ]] && rm -f "$LATEST_SNAPSHOT"
rm -f "$REPORT_FILE"
How to Use
- Save as
check_missing_mounts_with_email.sh chmod +x check_missing_mounts_with_email.sh- Run before patching → snapshot + email
- Run after reboot → full report with red alerts if anything is missing
Feel free to modify the EMAIL_TO line and the exclude list in get_real_mounts() as per your environment.
Never miss a mount point again after OS patching!
Posted by Abdul Muqeet | Oracle EBS Automation Series
No comments:
Post a Comment