Adjust ATS log processing mechanism and related scripts

Source: Internet
Author: User

In the attempt to use ATS, log processing is a very important link, I spent a lot of time in the study, First of all, our test ATS is 5.3.2 version, the default printing is binary log squid.blog, one day a cut, of course, can also become a text log, but ATS comes with a very good analysis traffic_logstats can not use, how to do? Thinking, finally think of a good way to play two sets of logs, text log archive, for us to see, binary log one day delete, haha, the problem is resolved satisfactorily. In order to meet the online traffic, log settings in order to 5 minutes a cut, after cutting renamed archive, while in order to reduce storage space, the definition of 3 o'clock in the morning (small traffic) to start packing compression, and then do the script found that the cross-year will fail, and once again made several optimizations, the current operation is still relatively robust, share out, Research and study together.

ATS log configuration Not much to say, previously introduced, here is a processing script I wrote:


#!/bin/sh
#writer: Gaolixu
Backup_path= "/var/log/ats"
Log_path= "/opt/ats/var/log/trafficserver"
Yestday= ' date-d yesterday +%d '
Yestmon= ' date-d yesterday +%m '
Yestyear= ' date-d yesterday +%y '
TestDir () {
backup_dir= $BACKUP _path/$1/$2/$3
if [!-d "$BACKUP _dir"]
Then
Mkdir-p $BACKUP _dir
If ["$?"! = "0"]
Then
echo "dir error"
Exit
Fi
Fi
}
Yestzip () {
Gzip $BACKUP _path/$yestyear/$yestmon/$yestday/*
}

CD $LOG _path

LS *.log*old >/tmp/atslog.tmp

For i in ' cat/tmp/atslog.tmp '

Do
I_time= ' echo $i |awk-f ' [. | -] ' {print $ (NF-2) $ (NF-1)} '
I_bj= ' echo $i |awk-f ' [. | -] ' {print '} '
I_year= ' echo ${i_time:0:4} '
I_mon= ' echo ${i_time:4:2} '
I_day= ' echo ${i_time:6:2} '
I_hour= ' echo ${i_time:8:2} '
I_min= ' echo ${i_time:11:2} '
TestDir $i _year $i _mon $i _day
MV $LOG _path/$i $BACKUP _dir/${i_year}-${i_mon}-${i_day}_${i_hour}_${i_min}_${i_bj}.log
If ["$i _hour" = "$i _min" = "xx"];then

Yestzip

rm-rf/opt/ats/var/log/trafficserver/squid.blog*

Fi

Done &>/dev/null


This article is from "Running Linux ..." Blog, be sure to keep this source http://benpaozhe.blog.51cto.com/10239098/1746637

Adjust ATS log processing mechanism and related scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.