You are on page 1of 6

#!

/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
#-------------------------------------------

TMP="set heading off\n


set feedback off\n
select COLLECTOR_id ||','||sum(SUCCESS_IN)||','||count(FILENAME_IN)||'
,'||sum(BILLING_OUT)||','\n
||sum(SMS_ENABLER)||','||sum(ICORE_OUT)\n
from BL_STATISTICS_COUNT \n
where TIME_STAMP like to_date('$Yesterday','YYYY/MM/DD') group by Collec
tor_id;\n
exit;"
echo $TMP > $Dir/tmp.txt
#------------------------------------------SERVER=`hostname`
if [[ $SERVER = bhpvma01 ]];then
sqlplus -s bv_fworks/pl31sew0rk@p1vma1d1.edc.cingular.net:1529/p1bfwks @
$Dir/tmp.txt> $Dir/tmp.out
elif [[ $SERVER = uhpvma01 ]];then
sqlplus -s av_fworks/pl31sew0rk@p2vma1d1.edc.cingular.net:1529/p1afwks @
$Dir/tmp.txt> $Dir/tmp.out
fi
#------------------------------------------#
PRINT function
#------------------------------------------function PRINT
{
awk 'BEGIN { FS=","
format1 ="\t\t%-20s %8s %15s %8s %15s %10s %10s\n";
format2 ="\t\t%-20s %8d %15d %8.1f %15d %10d %10d \n"
printf(format1, "COLLECTOR", "Files ","Input","Percent","Billing
","ENABLER", "ICORE");
printf(format1,"-----------","----------","---------","--------","---------","--------","--------")
}
{
printf(format2, $1, $3,$2,$7,$4,$5,$6);
}'
}
#------------------------------------------function PRINT1
{
awk 'BEGIN { FS=","
format1="\t\t%-20s %15s %15s %15s %15s %15s %15s\n";
}
{
printf(format1,$1,$2,$3,$4,$5,$6,$7);
}'
}
#------------------------------------------function PRINT2
{
awk 'BEGIN { FS=","
format1 ="\t\t\t%-20s%20s%20s\n";
}
{

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

Records=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{


s+=$2/1000}END{printf "%9.1f" ,s}')
PERC=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s+=
$2/1000000} END {printf "%9.1f", s/'$Total'*100}')
Files=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s+
=$3}END{printf "%15d" ,s}')
Billing=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{
s+=$4/1000}END{printf "%9.1f" ,s}')
Enabler=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{
s+=$5/1000}END{printf "%9.1f" ,s}')
Icore=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s+
=$6/1000}END{printf "%9.1f" ,s}')
printf "${VEN[$i]},$Files,$Records K,$PERC ,$Billing M,$Enabler K,$Icore
K\n " >>$Dir/tmp3.out
else
Records=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{
s+=$2/1000000}END{printf "%9.1f" ,s}')
PERC=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s+=
$2/1000000} END {printf "%9.1f", s/'$Total'*100}')
Files=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s+
=$3}END{printf "%15d" ,s}')
Billing=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{
s+=$4/1000000}END{printf "%9.1f" ,s}')
Enabler=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{
s+=$5/1000}END{printf "%9.1f" ,s}')
if [[ $Enabler -gt 1000 ]] ;then
Enabler1=$(printf "%9.1f" $(echo $Enabler|awk '{print $1/1000}')
)
Enabler="$Enabler1 M"
else
Enabler="$Enabler K"
fi
Icore=$(awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp.out|awk -F, '{s+
=$6/1000}END{printf "%9.1f" ,s}')
if [[ $Icore -gt 1000 ]] ;then
Icore1=$(printf "%9.1f" $(echo $Icore|awk '{print $1/1000}'))
Icore2="$Icore1 M"
else
Icore2="$Icore K"
fi
printf "${VEN[$i]},$Files,$Records M,$PERC,$Billing M,$Enabler ,$Icore2
\n " >>$Dir/tmp3.out
fi
((i = i + 1))
done
cat $Dir/tmp3.out|PRINT1 >>$Dir/$YES.Report
#------------------------------------------printf "\n" >>$Dir/$YES.Report
printf "\t\t\t__________________________________________________________________
______________\n" >>$Dir/$YES.Report
printf "\t\t\t%25s Records from other Switches
\n"
>>$Dir/$YES.Report
printf "\t\t\t__________________________________________________________________
______________\n" >>$Dir/$YES.Report

>$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

printf "\n" >>$Dir/$YES.Report


i=0
for type in NT AW ER NK LU AL SO
do
printf "\t\t____________________________________________________________________
__________________________\n" >>$Dir/$YES.Report
printf "\t\t %25s Report of ${VEN[$i]} Collectors for $Yesterday
\n"
>>$Dir/$YES.Report
printf "\t\t____________________________________________________________________
__________________________\n" >>$Dir/$YES.Report
awk -F, '($1 ~ /'$type'$/) {print $0}' $Dir/tmp5.out|sort|PRINT
Dir/$YES.Report
printf "\n\n">>$Dir/$YES.Report

>>$

(( 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 {} \;

You might also like