mmt sql
This commit is contained in:
72
scripts/fileLoadMailhtml_20210928.sh
Executable file
72
scripts/fileLoadMailhtml_20210928.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
#HOME="/home/compegence/customer"
|
||||
#Directories
|
||||
homeDir=$HOME/customer/MMT
|
||||
configDir=$homeDir/conf
|
||||
input_file=$configDir/etl-config.txt
|
||||
declare -A credentials
|
||||
while IFS="=" read -r key value; do
|
||||
credentials[$key]=$value
|
||||
done < <( sed -e '/^\s*$/ d' -e '/^#/ d' $input_file )
|
||||
|
||||
|
||||
user=${credentials[user]}
|
||||
password=${credentials[password]}
|
||||
host=${credentials[host]}
|
||||
db=${credentials[db]}
|
||||
protocol=${credentials[protocol]}
|
||||
server=${credentials[server]}
|
||||
|
||||
|
||||
|
||||
psql_base_arg="postgresql://$user:$password@$host/$db"
|
||||
|
||||
Get_Email_Ids () {
|
||||
#client_id=$1
|
||||
# echo $client_id
|
||||
email_ids=`psql $psql_base_arg -t -c "select runschedule_status_email from fw_core.fw_m_client where client_id=$client_id"`
|
||||
#echo $email_ids
|
||||
#mail -a "Content-type: text/html" -s "Mail configuration Completed" $email_ids -a "From: noreply@forewarn.com" < Output.html
|
||||
}
|
||||
#echo $psql_base_arg
|
||||
|
||||
Get_FileUpload_Status (){
|
||||
#echo -e "MIME-Version: 1.0\nContent-Type: multipart/plain" >Output.txt
|
||||
echo "<h4>**Latest Files Update Status**<h4>" > Output.html
|
||||
#echo " " >>Output.txt
|
||||
|
||||
psql $psql_base_arg -H -c "select run_schedule_id, file_syspk, file_mnemonic, file_name, end_status as status, end_time load_time from fw_core.fw_jobctl_file_runschedule
|
||||
where run_schedule_id in (select max(run_schedule_id) from fw_core.fw_jobctl_file_runschedule) order by run_schedule_id, file_syspk, end_status desc;" >> Output.html
|
||||
|
||||
|
||||
echo "<h4>**Error Files*****<h4>" >> Output.html
|
||||
|
||||
psql $psql_base_arg -H -c "select A.run_schedule_id, A.file_syspk, A.file_mnemonic, A.file_name, B.sheet_id, B.sheet_name, A.end_status, A.end_time load_time from fw_core.fw_jobctl_file_runschedule a, fw_core.fw_jobctl_file_sheet_runschedule b
|
||||
where a.run_schedule_id = (select max(run_schedule_id) from fw_core.fw_jobctl_file_runschedule) and a.file_syspk = b.file_syspk and (b.file_sheet_mnemonic != '' or b.file_sheet_mnemonic is not null) and b.end_status='error' order by A.run_schedule_id, b.file_syspk, b.sheet_id desc" >> Output.html
|
||||
|
||||
}
|
||||
|
||||
Send_Mail () {
|
||||
Get_Email_Ids
|
||||
echo $email_ids
|
||||
mail -a "Content-type: text/html" -s "Mail configuration Completed" $email_ids -a "From: noreply@forewarn.com" < Output.html
|
||||
}
|
||||
#mail -a "Content-type: text/html" -s "Mail configuration Completed" muin.shariff@compegence.com nagaraj.kulkarni@compegence.com dheepa.k@compegence.com abdur.rahman@compegence.com jagadish.puvvada@compegence.com -a "From: noreply@forewarn.com" < Output.html
|
||||
|
||||
|
||||
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "No argument supplied"
|
||||
echo "usage --> `basename ${0}` client_id"
|
||||
echo "Ex: `basename ${0}` 20"
|
||||
exit 1;
|
||||
else
|
||||
client_id=$1
|
||||
Get_FileUpload_Status
|
||||
Send_Mail;
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user