Вы находитесь на странице: 1из 3

#/****************************************************************************

# Title
: This is a weekly script which is used to report OM WOW and D
M WOW metrics fall out of range (+20 or -20)
# Filename
: dw_cmc.dw_ecare_rmscard_metrics_range.ksh
# Description : This shell will generate a HTML mail with the contents of th
e input DAT file
# Developer
: Cognizant Team
# Created on
: 03/11/2007
# Location
: $DW_EXE/
# Called By
: UC4
# Calls
:
# Date
Version
Modified By (Name)
Change and Reason for change
#-----------------------------------------------------------------------------# 03/11/2007
1
Cognizant Team
Initial Version
#******************************************************************************/
. /export/home/abinitio/cfg/abinitio.setup
time=`date '+%Y%m%d_%T'`
scriptName=`basename $0`
script=${scriptName%".ksh"}
export SUBJECT_AREA=${ETL_ID%%.*}
export TABLE_ID=${ETL_ID##*.}
#---------------------------# Declaring the Local variables
#---------------------------#MAILING_LIST=vbalasubrama@ebay.com,jgurusamy@ebay.com
MAILING_LIST=DL-eBay-RM-Scorecard-Alert@ebay.com
METRICS_RANGE_FILE=${DW_TMP}/${JOB_ENV}/${SUBJECT_AREA}/dw_cmc.dw_ecare_rmscard_
metrics_range_fail.dat
METRICS_RANGE_FILE_TMP=${DW_TMP}/${JOB_ENV}/${SUBJECT_AREA}/dw_cmc.dw_ecare_rmsc
ard_metrics_range_temp.dat
HTML_EMAIL=${DW_TMP}/${JOB_ENV}/${SUBJECT_AREA}/dw_cmc.dw_ecare_rmscard_metrics_
range_html_mail.dat
LOG_FILE=${DW_LOG}/${JOB_ENV}/${SUBJECT_AREA}/${script}.${time}.log
#-----------------------------------------#Check if the input data file exists or not
#-----------------------------------------if [ ! -e $METRICS_RANGE_FILE ]
then
echo "Error: Input data file $METRICS_RANGE_FILE not available" >> $LOG_FILE
exit 1
fi
#---------------------------------------------# If the DAT file has no records
#---------------------------------------------line_count=`cat $METRICS_RANGE_FILE | wc -l`
if [ ${line_count} -le 1 ]
then
echo "Error: No data to process in the formatted input file $METRICS_RAN
GE_FILE" >> $LOG_FILE
echo "Mail sent successfully to all users in the mailing list" >> $LOG_F

ILE
echo "ALL OM/DM METRICS ARE BOUND TO LOWER LIMIT(-20) AND UPPER LIMIT(+2
0)" > $HTML_EMAIL
cat $HTML_EMAIL | /usr/lib/sendmail "${MAILING_LIST}"
#Cleanup
rm -f $METRICS_RANGE_FILE
rm -f $HTML_EMAIL
exit 0
fi
#-----------------------------------------------------------------------# Formating the dat file(Adding Zero to the decimal part of metrics columns)
#-----------------------------------------------------------------------sed "s/|\./|0./g" $METRICS_RANGE_FILE > $METRICS_RANGE_FILE_TMP
mv $METRICS_RANGE_FILE_TMP $METRICS_RANGE_FILE
#-----------------------#Prepare the HTML tags
#-----------------------echo "content-type: text/html
From:
To: ${MAILING_DL}
Subject: Alert: OM/DM Metrics out of range" > $HTML_EMAIL
first_row=0
echo "<table border=1 cellspacing=1 cellpadding=1><font size=1 face=Arial>" >> $
HTML_EMAIL
while read record
do
echo "$record"
echo "$record"
echo "$record"
echo "$record"
echo "$record"

|
|
|
|
|

awk
awk
awk
awk
awk

-F"|"
-F"|"
-F"|"
-F"|"
-F"|"

'{print
'{print
'{print
'{print
'{print

$1}'
$2}'
$3}'
$4}'
$5}'

|
|
|
|
|

read
read
read
read
read

col1
col2
col3
col4
col5

if [ "$first_row" -eq 0 ]; then


echo "<tr align=center bgcolor=silver>
<td width=100>$col1</td>
<td width=380>$col2</td>
<td width=150>$col3</td>
<td width=150>$col4</td>
<td width=100>$col5</td>" >> $HTML_EMAIL
first_row=1
else
echo "<tr align=center>
<td align=center width=100>$col1</td>
<td align=left width=380>$col2</td>" >> $HTML_EMAIL
#----Logic to apply comma seperator to the input values
for varnum in 3 4
do
final=""
vartemp=$(eval echo "\$col$varnum")
strlen=`echo $vartemp | wc -c`

if [ $strlen -gt 7 ];then


final=,`echo $vartemp | cut -c$(($strlen - 6))-$(($strlen - 1)
)`$final
vartemp=$(echo $vartemp | cut -c0-$(($strlen - 7)))
strlen=`echo $vartemp | wc -c`
while [ $strlen -gt 4 ]; do
final=,`echo $vartemp | cut -c$(($strlen - 3))-$(($strlen - 1))`$f
inal
vartemp=$(echo $vartemp | cut -c0-$(($strlen - 4)))
strlen=`echo $vartemp | wc -c`
done
fi
echo "<td align=center width=150>$vartemp$final</td>" >> $HTML_EMAIL
done
echo "<td align=center width=100>$col5</td>
</tr>" >> $HTML_EMAIL
fi
done < $METRICS_RANGE_FILE
echo "</table>" >> $HTML_EMAIL
#-----------------------------------#Send the HTML mail format to DL
#-----------------------------------cat $HTML_EMAIL | /usr/lib/sendmail "${MAIL_DL}"
if [ $? -eq 0 ]
then
echo "Mail sent successfully to all users in the mailing list" >> $LOG_FILE
#Cleanup
rm -f $METRICS_RANGE_RESULT_FILE
rm -f $HTML_EMAIL
else
echo "Error:Unable to sent mail to the users" >> $LOG_FILE
exit 1
fi

Вам также может понравиться