Last active
August 29, 2015 14:21
-
-
Save Zane5/6d1ad614b00db7cc95d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# author: zheng | |
# date: 201505 | |
# version: 0.0.0 | |
# this file for merged the error-report log file | |
#path_work="/home/" | |
path_work="/home/" | |
echo $path_work | |
yesterday=`date -d yesterday +%Y%m%d` | |
if [ $1 != $yesterday ]; then | |
echo "the input date "$1 | |
yesterday=$1 | |
echo "Prepare process $yesterday data" | |
else | |
echo "Prepare process $yesterday data" | |
fi | |
echo $yesterday | |
yesterday_dash=`date -d $yesterday +%Y-%m-%d` | |
path_yesterday=$path_work$yesterday | |
echo "process path"$path_yesterday | |
if [ -d "$path_yesterday" ]; then | |
echo "clearn... $path_yesterday" | |
/bin/rm -rf $yesterday | |
mkdir -m 777 "$path_yesterday" | |
else | |
mkdir -m 777 "$path_yesterday" | |
fi | |
files_yesterday=$path_work"error-report.log."$yesterday_dash'*' | |
echo "36---"$files_yesterday | |
#find -name "error-report.log.2015-05-20*" -exec 'cat' {} \; > des | |
echo "merger the error-report log in $path_yesterday"/error-report-merger.log"" | |
for i in $files_yesterday | |
do | |
cat $i >> $path_yesterday"/error-report-merger.log"; | |
#echo $path_yesterday"/error-report-merger.log"; | |
done | |
echo "Generte 2060 log" | |
`grep -n ":2060" $path_yesterday"/error-report-merger.log" > $path_yesterday"/2060.log"` | |
echo "Generte submit_form log" | |
`grep -n "submit_form" $path_yesterday"/error-report-merger.log" > $path_yesterday"/submit_form.log"` | |
echo "Generte pv log" | |
`grep -n "pv" $path_yesterday"/error-report-merger.log" > $path_yesterday"/pv.log"` | |
echo "Generte mac: log" | |
`grep -n "mac:" $path_yesterday"/error-report-merger.log" > $path_yesterday"/mac.log"` | |
echo "Generte index data of the logs" | |
`wc -l $path_yesterday"/2060.log" >> "index_error_$yesterday.log"` | |
`wc -l $path_yesterday"/submit_form.log" >> "index_error_$yesterday.log"` | |
`wc -l $path_yesterday"/pv.log" >> "index_error_$yesterday.log"` | |
`wc -l $path_yesterday"/mac.log" >> "index_error_$yesterday.log"` | |
echo "mac failed:" >> "index_error_$yesterday.log" | |
`awk '{print $(NF-2) }' $path_yesterday"/mac.log" | sort| uniq -d | wc -l >> "index_error_$yesterday.log"` | |
echo "---------------" | |
`cat $path_yesterday"/2060.log" | wc -l >> "index_error_$yesterday.log"` | |
`cat $path_yesterday"/submit_form.log" | wc -l >> "index_error_$yesterday.log"` | |
`cat $path_yesterday"/pv.log" | wc -l >> "index_error_$yesterday.log"` | |
`cat $path_yesterday"/mac.log" | wc -l >> "index_error_$yesterday.log"` | |
echo "clearn... All the generted log files" | |
#rm -rf "$path_yesterday" | |
echo "All date have generted, pls check the index_error_$yesterday.log" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment