-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathstat-website-from-apache-log.sh
More file actions
executable file
·36 lines (28 loc) · 1023 Bytes
/
Copy pathstat-website-from-apache-log.sh
File metadata and controls
executable file
·36 lines (28 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#########################################################################
# File Name: guo.sh
# Author: Chun-Jie Liu
# Mail: chunjie-sam-liu@foxmail.com
#
#########################################################################
#!/bin/bash
# ! access log files
keyword=$1
# ! Test input keywords
[[ -z ${keyword} ]] && echo "Notice: Input the website name." && echo "Notice: such as gscalite or snoric." && exit
# ! apache2 log directory
log_dir="/var/log/apache2/"
logs=`find ${log_dir} -name "access*"`
archive_dir="/home/liucj/tmp/stat-web-access"
# ! output filename
today=`date +'%Y-%m-%d'`
filename="${archive_dir}/${keyword}-${today}.log"
[[ -f ${filename} ]] && true > ${filename}
for log in ${logs}
do
zgrep -i ${keyword} ${log} | awk -F ':' '{print $1}' | awk -F ' - - \\[' '{print $1,$2}' >> ${filename}
done
sed -i '/bin/Id' ${filename}
# ? plot website access by time
Rscript plot-access-by-time.R ${filename} &
# ? plot website access by location
Rscript plot-access-by-address.R ${filename} &