Reporting using Awk


Bingung kalo harus melihat File Log aslinya makanya saya perlu membuat Log Report sendiri, padahal outputnya seperti anda lihat sendiri dibawah

#!/bin/sh
#header
#Show MOSTLY USED MAP STAT for inniomp
#created by Beny Mardiyanto

#mgrep “MAP_STAT_TOT” -i /users1/homs/history/$1/HPHD/*.HPHD > ./temp_$1

print_it() {
#cat temp_$1 |egrep “DATE|REG:|CAN:|AUR:|QUD:|QUL:|LOR:|ROR:|FRQ:|TTN:|SMN:|SMR:” > temp_$1_1
awk ‘
BEGIN {
#print “+========================================================+”;
print ” Most Used MAP Statistics “;
#print “+========================================================+”;
}

#content
{
if ($1==”DATE”) {
print “+=======================================================+”;
printf (“| %s %s %s %s %s %s \t\t\t\t \n”,$1,$2,$3,$4,$5,$6);
print “+=======================================================+”;
print “| MAP Attempt Success Success Ratio |”;
print “+=======================================================+”;
} else {
if ($2==0) {
printf (“| %s\t%s\t\t%s\t\t%d %s \t\t%s\n”,$1,$2,$3,0,”%”,”|”);
} else {
if (length($3)>7) {
printf (“| %s\t%s\t%s\t%d %s \t\t%s\n”,$1,$2,$3,($3/$2)*100,”%”,”|”);
} else {
printf (“| %s\t%s\t\t%s\t\t%d %s \t\t%s\n”,$1,$2,$3,($3/$2)*100,”%”,”|”);
}
}
}
}

#end
END {
print “+=======================================================+”;
print “+================FIN of LINE============================+”;
}’ temp_1 |more
\rm -rf temp temp_1
}

case “$1” in
‘5min’)
mgrep “MAP_STAT_TOT” -i /users1/homs/history/$2/PPHD/*.PPHD > ./temp
cat temp |egrep “DATE|REG:|CAN:|AUR:|QUD:|QUL:|LOR:|ROR:|FRQ:|TTN:|SMN:|SMR:” > temp_1
print_it
;;
‘hour’)
mgrep “MAP_STAT_TOT” -i /users1/homs/history/$2/HPHD/*.HPHD > ./temp
cat temp |egrep “DATE|REG:|CAN:|AUR:|QUD:|QUL:|LOR:|ROR:|FRQ:|TTN:|SMN:|SMR:” > temp_1
print_it
;;
‘day’)
mgrep “MAP_STAT_TOT” -i /users1/homs/history/$2/PHD/*.PHD > ./temp
cat temp |egrep “DATE|REG:|CAN:|AUR:|QUD:|QUL:|LOR:|ROR:|FRQ:|TTN:|SMN:|SMR:” > temp_1
print_it
;;
*)
echo “usage: stat-map <5min|hour|day> <2008.06.23>”
exit 1
;;
esac

Sample outputnya begini nih :

SB1_KBL_BR_OMP: /users1/homs/beny % stat-map day 2008.10.27

============ START OF DATA ============
========== Message Statistic ==========

COUNT “STRING” DESCRIPTION
1 “MAP_STAT_TOT”
1 PRINT-MESSAGE
9 TOTAL-MESSAGE

============= END OF DATA =============

Most Used MAP Statistics
+=======================================================+
| DATE : 2008-10-26
+=======================================================+
| MAP   Attempt         Success         Success Ratio   |
+=======================================================+
| REG:   6357204         6357196         99 %              |
| CAN:  5382210         5371803         99 %              |
| AUR:  4697704         4697340         99 %              |
| QUD:  10111            8639               85 %               |
| QUL:  210638           210638           100 %            |
| LOR:  5900967         5900964         99 %              |
| ROR:  1644078         1643557         99 %              |
| FRQ:  855323           855316           99 %              |
| TTN:  570812           570795           99 %              |
| SMN:  89710            89688              99 %             |
| SMR:  3609663         3228822         89 %              |
+=======================================================+
+================FIN of LINE================================+

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: