清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/bin/env bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH shopt -s extglob clear; socketpath="/path1 /path2 /path3" log_cut() { for i in $(ls $1/LOG) ; do if [ $(date +"%Y%m%d") != $i] ; then wc -c -l $1/LOG/$i/* |awk '{printf "%s,%s,%s\n",$3,$1,$2}'|sort|sed '1 i\filename,rows,byte'|sed "1 i\\$1" >> /var/log/socketlog/report/report$i\.csv for j in $(ls $1/LOG/$i) ; do cd $1/LOG/$i case $j in @(getBlackList|Timetick|timetickEvent)\.txt) awk -F '\&|\=|-' '{++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times' > $2/${j%%.*}$i\.csv ;; @(getTime|getTrackPriceWithID|blaNamLiReq)\.txt) awk -F '\=|-' '{++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times'> $2/${j%%.*}$i\.csv ;; "cardSectionPrice.do.txt") 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'>$2/${j%%.*}$i\.csv ;; @(trans|InceptData)\.txt) 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'> $2/${j%%.*}$i\.txt ;; "blaNamLisDown.txt") awk -F '\=|-' '/pid/ {++S[$2]} END {for(a in S) printf "%s,%s\n",a,S[a]}' $j|sort |sed '1 i\Devid,Times'> $2/${j%%.*}$i\.csv ;; "corpCostData.txt") awk '{printf "%s\n",$2}' $j |sed '1 i\Devid'> $2/${j%%.*}$i\.txt ;; *\.txt) cp $j $2/${j%%.*}\_$i\.txt ;; *\.hlog) echo $j is hlog ;; *) echo $j ;; esac done rm -R $1/LOG/$i fi done } mymail(){ mailuser="xxx@xxx.com" day=$(date -d "yesterday" +"%Y%m%d") txt=$(cat /var/log/socketlog/report/report$day\.csv |awk -F "," '{if(/txt/){printf "%s , request %s times , %s byte<br> \n",$1,$2,$3}else if(!/hlog/){printf "<br>\n%s,%s,%s<br>",$1,$2,$3}}'|sed 's/.txt//g') logfile="/var/log/socketlog/report/report$day.csv" echo $txt |mutt -s "About the state of the interface from $day " -e 'set content_type="text/html"' $mailuser -a $logfile } [ ! -d /var/log/socketlog ] && mkdir /var/log/socketlog [ ! -d /var/log/socketlog/report ] && mkdir /var/log/socketlog/report for k in ${socketpath[@]} ; do [ -f "$k/asmsocket" ] && sfile="asmsocket" || sfile="ddtsocket" sport=`grep "Port" $k/config.txt| awk -F "\=" '{print $2}'|sed 's/\r//'` [ ! -d /var/log/socketlog/$sport ] && mkdir /var/log/socketlog/$sport if [ `netstat -tnl |awk '{print $4}'|awk -F "\:" '{print $2}'|grep "$sport"` ] ; then echo "$k/$sfile is starting now" else $k/$sfile 2>/dev/null & fi log_cut $k /var/log/socketlog/$sport done [ "00" -le $(date +"%H") -a "01" -ge $(date +"%H") ] && mymail