Report mail alert
#!/bin/bash
# Define database credentials
DB_USER="your_user"
DB_PASS="your_password"
DB_SID="your_db"
# Email Configuration
EMAIL_TO="recipient@example.com"
EMAIL_SUBJECT="OEM Target Report - $(date +%Y-%m-%d)"
REPORT_FILE="oem_target_report_$(date +%Y%m%d).txt"
# Function to execute SQL query and format output
run_query() {
SECTION_TITLE="$1"
QUERY="$2"
echo "=============================================" >> "$REPORT_FILE"
echo "SECTION: $SECTION_TITLE" >> "$REPORT_FILE"
echo "=============================================" >> "$REPORT_FILE"
sqlplus -s "$DB_USER/$DB_PASS@$DB_SID" <<EOF >> "$REPORT_FILE"
SET PAGESIZE 500
SET LINESIZE 200
SET HEADING ON
SET FEEDBACK OFF
SET TRIMSPOOL ON
COLUMN "TARGET NAME" FORMAT A30
COLUMN "TARGET TYPE" FORMAT A20
COLUMN "PROPERTY NAME" FORMAT A25
COLUMN "PROPERTY VALUE" FORMAT A40
COLUMN "HOST NAME" FORMAT A30
$QUERY
EOF
echo "" >> "$REPORT_FILE"
}
# Clear old report file
> "$REPORT_FILE"
# Define Queries (aligned OEM Management Target Report)
QUERY1="
SELECT target_name AS \"TARGET NAME\",
target_type AS \"TARGET TYPE\",
property_name AS \"PROPERTY NAME\",
property_value AS \"PROPERTY VALUE\",
host_name AS \"HOST NAME\"
FROM oem_targets
WHERE target_type = 'Database';"
QUERY2="
SELECT target_name AS \"TARGET NAME\",
target_type AS \"TARGET TYPE\",
property_name AS \"PROPERTY NAME\",
property_value AS \"PROPERTY VALUE\",
host_name AS \"HOST NAME\"
FROM oem_targets
WHERE target_type = 'Host';"
QUERY3="
SELECT target_name AS \"TARGET NAME\",
target_type AS \"TARGET TYPE\",
property_name AS \"PROPERTY NAME\",
property_value AS \"PROPERTY VALUE\",
host_name AS \"HOST NAME\"
FROM oem_targets
WHERE target_type = 'Listener';"
QUERY4="
SELECT target_name AS \"TARGET NAME\",
target_type AS \"TARGET TYPE\",
property_name AS \"PROPERTY NAME\",
property_value AS \"PROPERTY VALUE\",
host_name AS \"HOST NAME\"
FROM oem_targets
WHERE target_type = 'WebLogicServer';"
# Run queries and generate report
run_query "Database Targets" "$QUERY1"
run_query "Host Targets" "$QUERY2"
run_query "Listener Targets" "$QUERY3"
run_query "WebLogic Targets" "$QUERY4"
# Send report via email
mail -s "$EMAIL_SUBJECT" "$EMAIL_TO" < "$REPORT_FILE"
echo "OEM Target Report sent to $EMAIL_TO"
*******
Here’s a professionally worded, high-level summary you can share with your manager to project the automation work you've done:
---
Subject: OEM Target Property Validation Automation – Completed
Summary of Work Completed:
Automated OEM Property Validation:
Developed a shell script integrated with SQL*Plus to automatically extract and validate key OEM target properties (orcl_gtp_lifecycle_status, udtp_2, orcl_gtp_contact).
Multi-Query Consolidation into Unified Report:
Combined four distinct queries into a single, well-formatted report, categorizing outputs under meaningful sections (e.g., Missing Lifecycle Status, Missing Support Group, Missing Contact Info).
Structured Output with Alignment:
Implemented column formatting for consistent alignment of critical fields: Target Name, Target Type, Property Name, Property Value, and Host Name — making the report readable and manager-friendly.
Automated Daily Execution and Email Alerts:
Scheduled the script via cron to run daily, automatically emailing the report to stakeholders, reducing manual effort and ensuring timely visibility.
Improved Compliance & Data Accuracy:
This automation ensures property completeness across OEM targets, helping with CMDB alignment, audit readiness, and support coverage visibility.
---
Let me know if you'd like this adapted into an email draft or slid
e point for a presentation.
Comments
Post a Comment