#!/bin/bash
user='db_user'
pwd1='DBA%$#321'
start_date=$(date +"%Y-%m-%d")
end_date=$(date +"%Y-%m-%d")
#start_date="2020-01-09"
#end_date="2020-01-10"
point_time="00:00:00"
point_time1="09:05:00"
first_start_date="$start_date $point_time"
first_end_date="$end_date $point_time1"
#dataDate=`date +%F --date="1 day ago"`
reportDate=`date +"%Y-%m-%d %H:%M"`
#end_date=$(date +"%Y-%m-%d")
file_date=`date +"%Y-%m-%d"`
host_name1='192.168.103.54'
host_name2='192.168.103.71'
host_name3='192.168.103.76'
#outputDir="/home/applications/mail_alerts/status/DailyRainfall/$file_date/`date +%M`"
#/home/daily_raw_file
outputDir="/home/daily_raw_file/$file_date"
mkdir -p $outputDir
function mailAlert()
{
subject=$1
body=$2
successMsg=$3
attachments=$4
recepient="tarun.rajput@skymetweather.com,lekhraj.kothe@skymetweather.com,abhay.pandey@skymetweather.com,sanjay.more@skymetweather.com"
#recepient="lekhraj.kothe@skymetweather.com,abhay.pandey@skymetweather.com,sanjay.more@skymetweather.com,aher.rajesh@skymetweather.com,tarun.rajput@skymetweather.com,madhurema.nag@skymetweather.com,qcteam@skymetweather.com,malwadkar.bhagwan@skymetweather.com,ashwini.peter@skymetweather.com"
echo $subject | mailx -v -a $attachments -s "$subject" -S smtp="smtp.gmail.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="skymet.monitoring@gmail.com" -S smtp-auth-password="nAKeY2-u" -S ssl-verify=ignore -S nss-config-dir=/etc/pki/nssdb/ $recepient
}
function dailyRain()
{
#############call_Procedure_on_54_server#####################
mysql -h $host_name1 -u $user -p$pwd1 -e "call aws_mh.mahavedh_battery_count_summary('$first_start_date','$first_end_date');"
mysql -h $host_name2 -u $user -p$pwd1 -e "call aws_mh.mahavedh_battery_count_summary('$first_start_date','$first_end_date');"
mysql -h $host_name3 -u $user -p$pwd1 -e "call aws_mh.mahavedh_battery_count_summary('$first_start_date','$first_end_date');"
if [ "$?" -eq 0 ]
then
echo -e "calling of procedure is successfully done" >> $log_file_name
else
echo -e "calling of procedure is failed" >> $log_file_name
exit 1
fi
echo "Process_stationStatus_started_at_`date +%F_%H:%M`"
query54="select ID,DISTRICT,TEHSIL,REVENUE_CIRCLE,STATION_NAME, DD, last_reocrd_T ,No_Data_Packets, Batter_Voltage, Solar_panel_Voltage from
test.station_data_last_record "
query71="select ID,DISTRICT,TEHSIL,REVENUE_CIRCLE,STATION_NAME, DD, last_reocrd_T ,No_Data_Packets, Batter_Voltage, Solar_panel_Voltage from
test.station_data_last_record "
query76="select ID,DISTRICT,TEHSIL,REVENUE_CIRCLE,STATION_NAME, DD, last_reocrd_T ,No_Data_Packets, Batter_Voltage, Solar_panel_Voltage from
test.station_data_last_record "
echo "ExecutingOn54"
mysql -u $user -p$pwd1 -h 192.168.103.54 -P 3306 aws_mh -e "$query54" | sed 's/\t/,/g' > $outputDir/MHRaw_Date_$start_date.csv
echo "ExecutingOn71"
mysql -u $user -p$pwd1 -h 192.168.103.71 -P 3306 aws_mh -e "$query71" | sed 's/\t/,/g' | awk '{if(NR>1)print}' >> $outputDir/MHRaw_Date_$start_date.csv
echo "ExecutingOn76"
mysql -u $user -p$pwd1 -h 192.168.103.76 -P 3306 aws_mh -e "$query76" | sed 's/\t/,/g' | awk '{if(NR>1)print}' >> $outputDir/MHRaw_Date_$start_date.csv
mailAlert "Predictive Maintenance Raw Data Reports-$reportDate=." "PFA." "Predictive Maintenance" $outputDir/MHRaw_Date_$start_date.csv
echo "FileGeneratedAt: $outputDir/MHRaw_Date_$start_date.csv"
}
function main()
{
echo "@@@@@@@@@@@PROCESS-STARTED-AT-`date +%F_%H:%M`"
dailyRain
echo "@@@@@@@@@@@PROCESS-ENDED-AT-`date +%F_%H:%M`"
}
main
Wednesday, August 11, 2021
Subscribe to:
Post Comments (Atom)
Powered by Blogger.
No comments:
Post a Comment