#!/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\****' |sed "s/****/${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\****k' |sed "s/****k/${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.
\n",$1,$3}else if(!/hlog/){printf "
\n%s
",$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
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....