- Mount IIS log directory into Linux box
$ sudo mount -t cifs -o ro,username=USER,password=PASSWD //HOST_IP/SHARE /MOUNT_POINT
- Run
#!/bin/bash site_num=(1 2 7 8) site_addr=("AAA.com" "BBB.com" "CCC.com" "DDD.com") echo "SITE_NAME DATE WEEK TRAFFIC DB_CONN VISITOR" for ix in ${!site_num[*]} do d=${site_num[$ix]} for f in $(ls W3SVC$d) do if [[ ${f:4:6} -ge $(date -d 'last monday' +"%y%m%d") && ${f:4:6} -lt $(date +"%y%m%d") ]] then visitors=$(cat W3SVC$d/$f | grep ^[0-9] | awk '{if(!match($9, /^192.168./) && !match($9, /^10.10./)) print $9}' | sort | uniq | wc -l) sendbytes=$(cat W3SVC$d/$f | grep ^[0-9] | awk '{print $16}' | awk '{total=total+$1}END{printf "%.f", total}') dbconns=$(cat W3SVC$d/$f | awk '{if(match($5,/^\/$/) || match($5,/asp/)) print $9}' | wc -l) weeknum=$(date -dyesterday +%V) [ $(date -d yesterday +%u) -eq 1 ] && {mon=$(date -d yesterday +%m.%d); true} || mon=$(date -d last-monday +%m.%d) [ $(date -d yesterday +%u) -eq 7 ] && {sun=$(date -d yesterday +%m.%d); true} || sun=$(date -d sunday +%m.%d) printf "%s 20%s-%s-%s %s(%s-%s) %s %s %s\n" ${site_addr[$ix]} ${f:4:2} ${f:6:2} ${f:8:2} $weeknum %mon %sun $sendbytes $dbconns $visitors fi done done
- * Sample result
SITE_NAME DATE WEEK TRAFFIC DB_CONN VISITOR AAA.com 2013-08-25 34(08.19-08.25) 12329500782 54908 7335 BBB.com 2013-08-25 34(08.19-08.25) 13074318914 66700 6442 CCC.com 2013-08-25 34(08.19-08.25) 23734108053 140609 12877 DDD.com 2013-08-25 34(08.19-08.25) 8913154535 58417 5172
2013-08-23
Count number of visitors(IP addresses) with IIS log files
* Instruction
Labels:
Data Analysis,
Linux,
Server
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment