清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/bin/bash
##########################################################################################
# NOTE:
# The test system is Ubuntu12.04
#
# This Scripts all rights reserved deserved by MickeyZZC
# Copyright © 2013
#
##########################################################################################
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear;
function c_socket_log_cut()
{
for i in $(cd $log_path ; echo * )
do
echo "processing folder $i ,please wait a moment!"
if test $(date +"%Y%m%d") != $i
then
ls -lh $log_path/$i |awk '{print $NF,$5}' |sort > $file_path/$i\.report1
for j in $(cd $log_path/$i ; echo * )
do
echo "processing file $j ,please wait a moment!"
cd $log_path/$i
wc -l $j|awk '{print $2,$1}' >>$file_path/$i\.report2
if [ "getBlackList.txt" = $j -o "Timetick.txt" = $j ] ; then
# awk '/ask=0/ {split($2,S,"&");print S[1]}' $j |awk '{++S[$NF]} END {for(a in S) print a,S[a]}'
# awk -F '\&|\=' '/ask=0/ {++S[$2]} END {for(a in S) print a,S[a]}' $j
awk -F '\&|\=|-' '{++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times' > $file_path/${j%%.*}$i\.csv
elif [ "getTime.txt" = $j -o "getTrackPriceWithID.txt" = $j] ; then
awk -F '\=|-' '{++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times'> $file_path/${j%%.*}$i\.csv
elif [ "cardSectionPrice.do.txt" = $j ] ; then
awk -F '\=|-|#' '/data/ {if(/html/){printf "%s,0,false\n",$2}else{printf "%s,\"%s\",succeed\n",$2,$4}}' $j|sed '1 i\Devid,Data,Stats'>$file_path/${j%%.*}$i\.csv
elif [ "trans.txt" = $j -o "InceptData.txt" = $j ] ; then
awk -F '\&|\=|-' '{if(/T|true/){printf "%s,%s,T\n",$2,$4}else{printf "%s,%s,F\n",$2,$4}}' $j|sed '1 i\Data,Userid,Stats'> $file_path/${j%%.*}$i\.txt
elif [ "txt" = "${j##*.}" ] ;then
cp $j $file_path/${j%%.*}\_$i\.txt
fi
done
sort $file_path/$i\.report2 >$file_path/$i\.report3
join $file_path/$i\.report1 $file_path/$i\.report3 |sort |sed '1 i\fuck' |sed "s/fuck/${sockets[$num]}/">>$home_path/socketlog/${logs[3]}/report$i\.txt
rm $file_path/$i\.report1 $file_path/$i\.report2 $file_path/$i\.report3
rm -R $log_path/$i
fi
done
}
function c2_socket_log_cut()
{
for i in $(cd $log_path ; echo * )
do
echo "processing folder $i ,please wait a moment!"
if test $(date +"%Y%m%d") != $i
then
touch $file_path/$i.report
ls -lh $log_path/$i |awk '{print $NF,$5}' |sort > $file_path/$i\.report1
for j in $(cd $log_path/$i ; echo * )
do
echo "processing file $j ,please wait a moment!"
cd $log_path/$i
wc -l $j|awk '{print $2,$1}' >>$file_path/$i\.report2
if test "blaNamLiReq.txt" = $j -o "getTime.txt" = $j
then
awk -F '\=|-' '{++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times' > $file_path/${j%%.*}$i\.csv
elif test "blaNamLisDown.txt" = $j
then
awk -F '\=|-' '/pid/ {++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times'> $file_path/${j%%.*}$i\.csv
elif test "timetickEvent.txt" = $j
then
awk -F '\&|\=|-' '{++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times'> $file_path/${j%%.*}$i\.csv
elif test "corpCostData.txt" = $j
then
awk '{printf "%s\n",$2}' $j |sed '1 i\Devid'> $file_path/${j%%.*}$i\.txt
elif test "txt" = "${j##*.}"
then
cp $j $file_path/${j%%.*}\_$i\.txt
fi
done
sort $file_path/$i\.report2 >$file_path/$i\.report3
join $file_path/$i\.report1 $file_path/$i\.report3 |sort |sed '1 i\fuckk' |sed "s/fuckk/${sockets[$num]}/">>$home_path/socketlog/${logs[3]}/report$i\.txt
rm $file_path/$i\.report1 $file_path/$i\.report2 $file_path/$i\.report3
rm -R $log_path/$i
fi
done
}
function mymail()
{
mailuser="mickey@xxx.com"
day=$(date -d "yesterday" +"%Y%m%d")
txt=$(cat $home_path/socketlog/report/report$day\.txt |awk '{if(/txt/){printf "%s request %s times.<br> \n",$1,$3}else if(!/hlog/){printf "<br>\n%s<br>",$1}}'|sed 's/.txt//g')
logfile="$home_path/socketlog/${logs[1]}/*$day.csv /home/ecadmin/mail/Readme.txt"
echo $txt |mutt -s "About the state of the interface from $day " -e 'set content_type="text/html"' $mailuser -a $logfile
}
sockets=(c1_socket c2_socket)
logs=(l1 l2 l3 report)
home_path="/path"
for num in 0 1 2
do
log_path="$home_path/${sockets[$num]}/LOG"
file_path="$home_path/socketlog/${logs[$num]}"
if test "c2_socket" != ${sockets[$num]}
then
c_socket_log_cut
else
c2_socket_log_cut
fi
done
mymail