Professional Documents
Culture Documents
DailySummary KSH
DailySummary KSH
/usr/bin/ksh
#####################################################################
# Script to get Collector Usage
#####################################################################
# HISTORY
#====================================================================
# Date
! Description
!
ORI.
!
#====================================================================
#04/20/2008 ! Creation 1.0.1
!
km444k
!
#-------------------------------------------------------------------#
#-------------------------------------------------------------------Dir=${HOME}/scripts/report
MAILOUT_LIST="dl-mediationsupport@att.com"
#MAILOUT_LIST="km444k@att.com"
#------------------------------------------#
yesterday date
#------------------------------------------dd=`date +%d`
mm=`date +%m`
YY=`date +%Y`
y_YY=$YY
y_mm=$mm
let "y_dd=dd-1"
if
(( dd==1 ))
then
let y_mm=mm-1
echo $y_mm
case $y_mm in
1|3|5|7|8|10|0 )
y_dd=31 ;;
4|6|9|11 )
y_dd=30 ;;
2)
if (( YY%4 == 0 ))
then y_dd=29
else y_dd=28
fi
;;
esac
if (( mm==1 ))
then
let y_YY=YY-1
y_mm=12
fi
fi
typeset -Z2 mm dd
y_mm y_dd
Yesterday=$y_YY/$y_mm/$y_dd
YES=$y_YY-$y_mm-$y_dd
#------------------------------------------MAIL_FILE=$Dir/$YES.Report
#------------------------------------------#
SQL Querry
#-------------------------------------------
printf(format1,$1,$2,$3);
}'
}
#------------------------------------------>$Dir/$YES.Report
#------------------------------------------# Printing
#---------------------------------------#Total GSM usage:
printf "\t\t\t__________________________________________________________________
__________\n" >>$Dir/$YES.Report
printf "\t\t\t%25s Total Voice Records for $YES
\n"
>>$Dir/$YES.Report
printf "\t\t\t__________________________________________________________________
__________\n" >>$Dir/$YES.Report
grep -v ^$ $Dir/tmp.out|awk -F, '($1 ~ /NK$|NT$|LU$|AL$|ER$|AW$/) {print
$0}'|awk -F, '{s+=$2/1000000}\
END {printf "\t\t\t\tTotal GSM Records=%10.1f Million\n",s}'>>$Dir/$YES.
Report
Total=$(grep -v ^$ $Dir/tmp.out|awk -F, '($1 ~ /NK$|NT$|LU$|AL$|ER$|AW$/
) {print $0}' |awk -F, '{s+=$2/1000000}END{print s}')
grep -v ^$ $Dir/tmp.out|awk -F, '{print $0}'|sort|awk -F, '{s+=$5/100000
0}\
END {printf "\t\t\t\tTotal SMS Records=%10.1f Million\n",s}'>>$Dir/$YES.
Report
printf "\n" >>$Dir/$YES.Report
printf "\t\t\t__________________________________________________________________
_________\n" >>$Dir/$YES.Report
printf "\t\t \t%25s Records by Switch Type
\n"
>>$Dir/$YES.Report
printf "\t\t\t__________________________________________________________________
_________\n" >>$Dir/$YES.Report
printf "\n\n" >>$Dir/$YES.Report
>$Dir/tmp3.out
typeset VEN[0]="Nortel BD" VEN[1]="Nortel BLUE" VEN[2]=Ericsson VEN[
3]=Nokia VEN[4]=Lucent VEN[5]=Alcatel VEN[6]=Sonus
printf 'SWITCH TYPE,TOTAL Files,Input Records,Percent,Billing,ENABLER,ICORE\n' >
$Dir/tmp3.out
printf '-----------,-----------,-------------,--------,--------,-------,------\n
' >>$Dir/tmp3.out
i=0
for type in NT AW ER NK LU AL
do
sum=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s+=$
2}END{printf "%50d", s}')
if [[ -z $sum ]] || [[ $sum -eq 0 ]] ; then
echo " Nothing" > /dev/null
elif
[[ $sum -lt 1000000 ]]; then
>$Dir/tmp3.out
typeset VEN1[0]="Push to Talk" VEN1[1]="Tell Me" VEN1[2]=Cirle VEN1[3]=ONNETV
M VEN1[4]=OFFNETVM VEN1[5]=B0EC1205VA
i=0
for type in KO TM CI ONNETVM OFFNETVM B0EC1205VA
do
sum=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F
, '{s+=$2}END{printf "%50d", s}')
if [[ -z $sum ]] || [[ $sum -eq 0 ]] ; then
echo " Nothing" > /dev/null
elif
[[ $sum -lt 1000000 ]]; then
switch=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s
+=$2/1000}END{printf "%9.1f" ,s}')
printf "${VEN1[$i]},Records=$switch K\n" >>$Dir/tmp3.out
else
switch=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk
-F, '{s+=$2/1000000}END{printf "%9.1f" ,s}')
printf "${VEN1[$i]},Records=$switch M\n" >>$Dir/tmp3.out
fi
((i = i + 1))
done
cat $Dir/tmp3.out|PRINT2 >>$Dir/$YES.Report
#-------------------------------------------
#------------------------------------------> $Dir/tmp5.out
#------------------------------------------for type in NT AW ER NK LU AL SO
do
sum=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk F, '{s+=$2}END{print s}')
awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out >$Dir/tmp3.
out
>$Dir/tmp4.out
cat $Dir/tmp3.out|while read line
do
Rec=$(printf ",%9.1f" $(echo $line|awk -F, '{print $2*100/'$sum'
}'))
echo $Rec >>$Dir/tmp4.out
done
paste $Dir/tmp3.out $Dir/tmp4.out >> $Dir/tmp5.out
done
>>$
(( i = i + 1 ))
done
#------------------------------------------rm $Dir/tmp.out;rm $Dir/tmp.txt;rm $Dir/tmp3.out;rm $Dir/tmp4.out;rm $Dir/tm
p5.out
#------------------------------------------mailx -s "'Voice Daily Production Status for $SERVER dated: $YES'" $MAILOUT_LIS
T < $MAIL_FILE
#------------------------------------------find $Dir \( -name "2008*.Report" \) -mtime +5 -exec rm {} \;