Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Adjust ATS log processing mechanism and related scripts

Shulou Source: shulou.com Published: 2022-06-01 05:05:21 10月04日 Update

In the attempt to use ATS, log processing is a very important part, I spent a lot of energy in the study of this time, first of all, we test the ATS is 5.3.2 version, the default print is the binary log squid.blog, a day everything cut, of course, can also be turned into a text log, but ATS comes with a very powerful analysis of traffic_logstats can not be used, how to do? Think hard, finally came up with a good way, play two sets of logs, text log archive, for us to see, binary log a day to delete, , the problem is solved successfully. In order to cater to the online traffic, the log is set to cut everything in 5 minutes, and then renamed and archived. At the same time, in order to reduce the storage space, it is defined that packaging and compression will begin at 3: 00 in the morning (with a small number of visitors). When doing the script, we found that there would be a failure during the Spring Festival, and we made many optimizations again. At present, it is still relatively robust. Share it and study and learn together.

I won't say much about the log configuration of ATS. I've introduced it before. here's a processing script I wrote:

#! / bin/sh#writer:gaolixuBACKUP_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/$3if [!-d "$BACKUP_DIR"] then mkdir-p $BACKUP_DIR if ["$?"! = "0"] then echo " Dir error "exit fifi} yestzip () {gzip $BACKUP_PATH/$yestyear/$yestmon/$yestday/*} cd $LOG_PATHls * .log*old > / tmp/atslog.tmpfor I in `cat / tmp/ atslog.tmp`do icalendar time= `echo $I | awk-F' [. | -]'{print $(NF-2) $(NF-1)} '`iechobj = `echo $I | awk-F' [. | -]' {print $1} '`iyears = `echo ${echo I_time:0:4} `ichimmon`echo ${i_time:4:2} `idayday = `echo ${i_time:6:2} `idecihour`echo ${i_time:8:2} `idecimin` testdir $i_year $i_day mv $LOG_PATH/$i $BACKUP_DIR/$ {i_year}-${i_mon}-${i_day} _ ${i_hour} _ ${i_min} _ ${i_bj} .log if ["$i_hour" = "03"-a "$i_min" = "00"] Then yestzip rm-rf / opt/ats/var/log/trafficserver/squid.blog* fi done & > / dev/null

Build your own original station, Operation and maintenance Web Service (www.net-add.com). The new blog will be updated on the Internet. Welcome to visit.

Tags: Logs scripts processing binaries text visits Tianyi research robust important meditation personal again at the same time year what to do failure time introduction version Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Apple Redmi MySQL OPPO Reno