shell 分析iosapi接口调用情况

一、代码展示
#!/bin/bash
INIT_PATH="/opt/phpdba/apache/logs"
FILEGREP='1208'
Date='08/Dec/2013'
hour=`cat hour.txt`

for a in $hour
do
i=($(echo $a|awk -F'/' '{print $1}'))
e=($(echo $a|awk -F'/' '{print $2}'))

cat $INIT_PATH/www.phpdba.com-access.$FILEGREP |grep $Date$i|grep 'ios/api'|awk -F'"'  '{print $2" "$3" "$1}'>>phpdba/${e}_iosapi.log
cat $INIT_PATH/www.phpdba.com-access.$FILEGREP |grep $Date$i|grep 'ios/api'|awk -F'"'  '{print $6}'>>phpdba/${e}_iosapi_refer2.log
cat phpdba/${e}_iosapi_refer2.log |sort -rn|uniq -c|sort -rn>>phpdba/${e}_iosapi_refer_sort.log
cat phpdba/${e}_iosapi.log |awk '{print $1" "$2" "$(NF-6)}'>>phpdba/${e}_iosapi_good.log
cat phpdba/${e}_iosapi_good.log |awk '{print $3" "$1" "$2}'>>phpdba/${e}_iosapi_good_new.log
cat phpdba/${e}_iosapi_good_new.log|awk -F'?' '{print $1}'>>phpdba/${e}_iosapi_good_ok.log
cat phpdba/${e}_iosapi_good_ok.log|sort -rn|uniq -c |sort -rn>>phpdba/${e}_iosapi_good_ok_sortip.log
cat phpdba/${e}_iosapi_good_ok.log|awk '{print $3}'|sort -rn|uniq -c |sort -rn>>phpdba/${e}_iosapi_good_ok_urlsort.log
cat phpdba/${e}_iosapi_good_ok.log|awk '{print $2" "$3}'|sort -rn|uniq -c |sort -rn>>phpdba/${e}_iosapi_good_ok_getpost.log
num=`cat phpdba/${e}_iosapi_good_ok.log|wc -l`
echo "$e => $num">>phpdba/time_total.txt
cat phpdba/${e}_iosapi_good_ok_getpost.log>>phpdba/iosapi_good_ok_getpost_total.log
cat phpdba/${e}_iosapi_good_ok_sortip.log>>phpdba/iosapi_good_ok_sortip_total.log
cat phpdba/${e}_iosapi_good_ok_urlsort.log>>phpdba/iosapi_good_ok_urlsort_total.log

done
cat phpdba/iosapi_good_ok_getpost_total.log |awk '{arr[$2" "$3]+=$1}END{for(s in arr) print arr[s],s}'|sort -rn>>phpdba/iosapi_good_ok_getpost_total_ok.txt
cat phpdba/iosapi_good_ok_sortip_total.log |awk '{arr[$2]+=$1}END{for(s in arr) print arr[s],s}'|sort -rn>>phpdba/iosapi_good_ok_sortip_total_ok.txt
cat phpdba/iosapi_good_ok_sortip_total.log |awk '{arr[$3" "$4]+=$1}END{for(s in arr) print arr[s],s}'|sort -rn>>phpdba/iosapi_good_ok_sortip_total_ok2.txt
cat phpdba/iosapi_good_ok_sortip_total.log |awk '{arr[$4]+=$1}END{for(s in arr) print arr[s],s}'|sort -rn>>phpdba/iosapi_good_ok_sortip_total_ok3.txt
cat phpdba/iosapi_good_ok_urlsort_total.log |awk '{arr[$2]+=$1}END{for(s in arr) print arr[s],s}'|sort -rn>>phpdba/iosapi_good_ok_urlsort_total_ok.txt 

二、代码下载
phpdba.tar
此条目发表在技术生涯分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注