質問編集履歴
1
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1,95 @@
|
|
1
1
|
UTC時刻で出力されているアクセスログをJSTに読み替えて集計したいのですが、いい方法なないでしょうか。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
以下のようなファイルが出力されるので、先頭の(20200501)が日付でファイル名で集計してました。
|
6
|
+
|
7
|
+
20200501T000000.000-WstSAefuOVd4ZYO34n94.log.gz
|
8
|
+
|
9
|
+
20200531T230000.000-WstSAefuOVd4ZYO34n94.log.gz
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```bash
|
14
|
+
|
15
|
+
#!/bin/sh
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
#################################################
|
20
|
+
|
21
|
+
##File list with 50 or more access to / xyz / std ${YEAR}
|
22
|
+
|
23
|
+
#################################################
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
YEAR=$(date "+%Y")
|
28
|
+
|
29
|
+
MM=$1
|
30
|
+
|
31
|
+
SECONDS=0
|
32
|
+
|
33
|
+
LOGFILE="/tmp/js_`date +%Y%m%d_%H%M%S`.log"
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
exec > "${LOGFILE}"
|
38
|
+
|
39
|
+
exec 2>&1
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
if [ "$#" -ne 1 ]; then
|
44
|
+
|
45
|
+
echo "Argument error!"
|
46
|
+
|
47
|
+
exit 1
|
48
|
+
|
49
|
+
elif [[ ! "$MM" =~ [0-1][0-9] ]]; then
|
50
|
+
|
51
|
+
echo "Argument error!"
|
52
|
+
|
53
|
+
echo "Enter the month!"
|
54
|
+
|
55
|
+
exit 1
|
56
|
+
|
57
|
+
fi
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
test -f ${YEAR}-${MM}-${i}.json && echo "already exists ${YEAR}-${MM}-${i}.json" && exit 1
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
66
|
+
|
67
|
+
do
|
68
|
+
|
69
|
+
zcat "${YEAR}${MM}${i}"*.log.gz | awk -F \" '{print $8}' |
|
70
|
+
|
71
|
+
grep -E "/xyz/std/[0-9]*/[0-9]*/[0-9]*.png$" |
|
72
|
+
|
73
|
+
cut -d "?" -f 1 |cut -d "%" -f 1 |cut -d "#" -f 1 |
|
74
|
+
|
75
|
+
sort |uniq -c |awk '$1 >= 50 {print $2","$1}' > ${YEAR}-${MM}-${i}.json
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
sed -i -e "s/^/[\"/g" ${YEAR}-${MM}-${i}.json
|
80
|
+
|
81
|
+
sed -i -e "s/.png/.png\"/g" ${YEAR}-${MM}-${i}.json
|
82
|
+
|
83
|
+
sed -i -e "s/$/],/g" ${YEAR}-${MM}-${i}.json
|
84
|
+
|
85
|
+
sed -i -e "1i {addressPoints:[" ${YEAR}-${MM}-${i}.json
|
86
|
+
|
87
|
+
sed -i -e "$ s/],/]]}/g" ${YEAR}-${MM}-${i}.json
|
88
|
+
|
89
|
+
done
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
echo "[INFO] Script time is ${SECONDS}sec."
|
94
|
+
|
95
|
+
```
|