#!/bin/bash
# Oracle DB Connection Details
USERNAME="your_oracle_username"
PASSWORD="your_oracle_password"
DATABASE="your_oracle_sid"
# Email Details
SUBJECT="Oracle DB Query Results"
RECIPIENT="recipient_email@example.com"
SENDER="sender_email@example.com"
# Execute the first SQL query
QUERY1_OUTPUT=$(sqlplus -s $USERNAME/$PASSWORD@$DATABASE <<EOF
SET PAGESIZE 500
SET LINESIZE 200
SELECT component_name, component_status FROM fnd_svc_components WHERE component_type = 'WF_MAILER';
EXIT;
EOF
)
# Execute the second SQL query
QUERY2_OUTPUT=$(sqlplus -s $USERNAME/$PASSWORD@$DATABASE <<EOF
SET LINESIZE 155
SET PAGESIZE 200
SET VERIFY OFF
COLUMN MANAGER FORMAT A15
COLUMN MEANING FORMAT A15
SELECT concurrent_queue_name manager, fcp.last_update_date, fcp.concurrent_process_id pid, meaning, fcp.logfile_name
FROM fnd_concurrent_queues fcq, fnd_concurrent_processes fcp, fnd_lookups flkup
WHERE concurrent_queue_name IN ('WFMLRSVC')
AND fcq.concurrent_queue_id = fcp.concurrent_queue_id
AND fcq.application_id = fcp.queue_application_id
AND flkup.lookup_code=fcp.process_status_code
AND lookup_type ='CP_PROCESS_STATUS_CODE'
AND meaning='Active';
EXIT;
EOF
)
# Compose the email body
EMAIL_BODY="First Query Result:\n$QUERY1_OUTPUT\n\nSecond Query Result:\n$QUERY2_OUTPUT"
# Send the email
echo "$EMAIL_BODY" | mailx -s "$SUBJECT" -r "$SENDER" "$RECIPIENT"
echo "Script executed and email sent successfully."
No comments:
Post a Comment