1、 将脚本collect.sh上传至业务程序家目录$ENIP_HOME下
2、执行下述命令赋予文件执行权限
chmod a+7 collect.sh
3、按照如下格式执行话单统计
./collect.sh 用户账号日期
用户账号:即要统计的目标号码(没有格式要求)
日期:格式须如20140101相同
4、举例说明:
<218 linux [core] :/home/test>./test.sh 861064298888 20140104
861064298888 Total send times is: 16380 //用户在20141008当天发送短信数量
--------------------------------------------
861064298888 Total success receive times is: 16434 //用户在20141008当天接收成功回执数量
--------------------------------------------
861064298888 Total fail receive times is: 0 //用户在20141008当天接收失败回执数量
--------------------------------------------
861064298888 Total receive times is: 16434 //用户在20141008当天接收回执总数
--------------------------------------------
861064298888 Total repeat_send times is: 0 //用户在20141008当天由于失败重复发送回执的数量
shell脚本如下:
#!/bin/bash
#set -x
ACCOUNT=$1
DATE=$2
SENDACCOUNT=`find ./cdr/sipmobill/bak -name "*$2*.unl" | xargs more | awk -F, '{if ($2==3 && $4~/'$ACCOUNT'/) print $0}' | wc -l`
RECEIVE_SUCCESS=`find ./cdr/sipmtbill/bak -name "*$2*.unl" | xargs more | awk -F, '{if (($2==7 && $8~/'$ACCOUNT'/) && $17==200) print $1}' | sort | uniq -c | wc -l`
RECEIVE_FAIL=`find ./cdr/sipmtbill/bak -name "*$2*.unl" | xargs more | awk -F, '{if (($2==7 && $8~/'$ACCOUNT'/) && $17!=200) print $1}'| sort | uniq -c | wc -l`
RECEIVE_ALL=`find ./cdr/sipmtbill/bak -name "*$2*.unl" | xargs more | awk -F, '{if ($2==7 && $8~/'$ACCOUNT'/) print $1}'| sort | uniq -c | wc -l`
REPEAT_SEND=`find ./cdr/sipmtbill/bak -name "*$2*.unl" | xargs more | awk -F, '{if (($2==7 && $9!=1 ) && ($17==200 && $8~/'$ACCOUNT'/)) print $0}'| sort | uniq -c | wc -l`
echo -e "\n"
if [ -z $SENDACCOUNT ]; then
echo -e "$1 total send times is: 0\n"
else
echo -e "$1 Total send times is: $SENDACCOUNT\n"
fi
echo -e "--------------------------------------------\n"
if [ -z $RECEIVE_SUCCESS ]; then
echo -e "$1 total success receive times is: 0\n"
else
echo -e "$1 Total success receive times is: $RECEIVE_SUCCESS\n"
fi
echo -e "--------------------------------------------\n"
if [ -z $RECEIVE_FAIL ]; then
echo -e "$1 total fail receive times is: 0\n"
else
echo -e "$1 Total fail receive times is: $RECEIVE_FAIL\n"
fi
echo -e "--------------------------------------------\n"
if [ -z $RECEIVE_ALL ]; then
echo -e "$1 total receive times is: 0\n"
else
echo -e "$1 Total receive times is: $RECEIVE_ALL\n"
fi
echo -e "--------------------------------------------\n"
if [ -z REPEAT_SEND ]; then
echo -e "$1 total repeat_send times is: 0\n"
else
echo -e "$1 Total repeat_send times is: $REPEAT_SEND\N"
fi
#set +x