Skip to content

Commit b06bef0

Browse files
Merge remote-tracking branch 'RobertD502/add_browsers_list' into develop
2 parents f9d4ac1 + 521c9d7 commit b06bef0

File tree

9 files changed

+256
-24
lines changed

9 files changed

+256
-24
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN make install
2323
WORKDIR /goaccess
2424
RUN cp /goaccess-temp/goaccess.tar.gz .
2525
RUN tar --strip-components=1 -xzvf goaccess.tar.gz
26-
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> ( <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.20<\/span> )/" /goaccess/resources/tpls.html
26+
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> ( <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.21<\/span> )/" /goaccess/resources/tpls.html
2727
RUN sed -i "s/bottom: 190px/bottom: 260px/" /goaccess/resources/css/app.css
2828
RUN ./configure --enable-utf8 --enable-geoip=mmdb --with-getline
2929
RUN make

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Still in development... You might need to wait a bit if you have a large amount
1515

1616
**Dependencies:**
1717
- GoAccess version: 1.7.2
18-
- GeoLite2-City.mmdb (2023-08-10)
19-
- GeoLite2-Country.mmdb (2023-08-10)
20-
- GeoLite2-ASN.mmdb (2023-08-10)
18+
- GeoLite2-City.mmdb (2023-09-09)
19+
- GeoLite2-Country.mmdb (2023-09-09)
20+
- GeoLite2-ASN.mmdb (2023-09-09)
2121

2222
---
2323

@@ -57,6 +57,8 @@ services:
5757
- BASIC_AUTH_PASSWORD=pass #optional
5858
- EXCLUDE_IPS=127.0.0.1 #optional - comma delimited
5959
- LOG_TYPE=NPM #optional - more information below
60+
- ENABLE_BROWSERS_LIST=True #optional - more information below
61+
- CUSTOM_BROWSERS=Kuma:Uptime,TestBrowser:Crawler #optional - comma delimited, more information below
6062
volumes:
6163
- /path/to/host/nginx/logs:/opt/log
6264
- /path/to/host/custom:/opt/custom #optional, required if using log_type = CUSTOM
@@ -82,6 +84,8 @@ services:
8284
- BASIC_AUTH_PASSWORD=pass #optional
8385
- EXCLUDE_IPS=127.0.0.1 #optional - comma delimited
8486
- LOG_TYPE=NPM #optional - more information below
87+
- ENABLE_BROWSERS_LIST=True #optional - more information below
88+
- CUSTOM_BROWSERS=Kuma:Uptime,TestBrowser:Crawler #optional - comma delimited, more information below
8589
volumes:
8690
- /path/to/host/nginx/logs:/opt/log
8791
- /path/to/host/custom:/opt/custom #optional, required if using log_type = CUSTOM
@@ -99,6 +103,8 @@ services:
99103
| `-e LOG_TYPE=` | (Optional) By default the configuration will be set to read NPM logs. Options are: CUSTOM, NPM, NPM+R, TRAEFIK, NCSA_COMBINED. More information below.|
100104
| `-e LOG_TYPE_FILE_PATTERN=` | (Optional) Only to be used with LOG_TYPE=NCSA_COMBINED or TRAEFIK. This parameter will pass along the file type you are trying match. For example you can pass -e LOG_TYPE_FILE_PATTERN="*.log" or -e LOG_TYPE_FILE_PATTERN="access.log". The default is *.log. Please keep it simple as I have not tested this completely. Use at your own RISK! |
101105
| `-e LANG=zh_CN.UTF-8 -e LANGUAGE=zh_CN.UTF-8` | (Optional) Language localization added. GoAccess only has a few translations available. Please visit https://github.com/allinurl/goaccess/tree/master/po to see the translations available. <br/><br/>**Current Translations**<br/>de - German<br/>es - Spanish<br/>fr - French<br/>it - Italian<br/>ja - Japanese<br/>ko - Korean<br/>pt_BR - Portuguese (Brazil)<br/>ru - Russian<br/>sv - Swedish<br/>uk - English (United Kingdom)<br/>zh_CN - Chinese - Simplified|
106+
| `-e ENABLE_BROWSERS_LIST=True/False` | (Optional) Defaults to False. Set to true if you would like to enable the [goaccess browsers.list](https://github.com/allinurl/goaccess/blob/master/config/browsers.list) file. |
107+
| `-e CUSTOM_BROWSERS=` | - (Optional) Consumes the list of provided custom browsers. This is a comma separated list containing the custom browser(s) in the format `Browser:Browser_category`.<br/>- If your custom browser is already defined in the default `browsers.list` file, it will not be added. However, the `Browser_category` can be reused.<br/><br/> CUSTOM_BROWSERS list example: `Kuma:Crawlers,TestBrowser:Crawlers,Kuma:Uptime,Discordbot:Crawlers`<br/><br/>For the example above, only `Kuma:Crawlers` and `TestBrowser:Crawlers` will be appended to the `browsers.list` file. <br/><br/>`Kuma:Uptime` is ignored as the browser `Kuma` has already been defined in `Kuma:Crawlers`. `Discordbot:Crawlers` is ignored as the browser `Discordbot` is already defined in the [default browsers.list file](https://github.com/allinurl/goaccess/blob/master/config/browsers.list)<br/><br/>Note for users using CUSTOM LOG_TYPE:<br/><br/>If your `goaccess.conf` file references a browsers.list file other than the one located in the `/goaccess-config/ directory`, the CUSTOM_BROWSERS variable will be ignored. |
102108

103109

104110
# **Additional environment information**

resources/scripts/logs/custom.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ function custom_init(){
2929
fi
3030
if [[ -r ${goan_config} ]]; then
3131
echo -e "goaccess.conf readable"
32+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
33+
if grep -Fwq "browsers-file" ${goan_config}; then
34+
echo -e "\n\t\BROWSERS FILE ALREADY DEFINED IN CUSTOM GOACCESS.CONF. IGNORING CUSTOM_BROWSERS VARIABLE"
35+
else
36+
echo -e "\n\tENABLING CUSTOM INSTANCE GOACCESS BROWSERS LIST"
37+
browsers_file="/goaccess-config/browsers.list"
38+
echo "browsers-file ${browsers_file}" >> ${goan_config}
39+
fi
40+
fi
3241
else
3342
echo -e "goaccess.conf not readable"
3443
#exit
@@ -61,4 +70,4 @@ function custom(){
6170
/goaccess/goaccess --no-global-config --config-file=${goan_config} &
6271
fi
6372

64-
}
73+
}

resources/scripts/logs/ncsa_combined.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function ncsa_combined_init(){
2121
if [[ -f ${html_config} ]]; then
2222
rm ${html_config}
2323
fi
24-
24+
2525
echo -n "" > ${archive_log}
2626
echo -n "" > ${active_log}
2727
}
@@ -36,9 +36,14 @@ function ncsa_combined_goaccess_config(){
3636
echo "date-format %d/%b/%Y" >> ${goan_config}
3737
#echo "log-format [%d:%t %^] %^ %s %^ %^ %m %^ %v \"%U\" [%^ %h] [%^ %b] %^\"%u\" \"%R\"" >> ${goan_config}
3838
echo "log-format %h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"" >> ${goan_config}
39-
echo "port 7890" >> ${goan_config}
39+
echo "port 7890" >> ${goan_config}
4040
echo "real-time-html true" >> ${goan_config}
4141
echo "output ${nginx_html}" >> ${goan_config}
42+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
43+
echo -e "\n\tENABLING NCSA_COMBINED INSTANCE GOACCESS BROWSERS LIST"
44+
browsers_file="/goaccess-config/browsers.list"
45+
echo "browsers-file ${browsers_file}" >> ${goan_config}
46+
fi
4247
}
4348

4449
function ncsa_combined(){
@@ -58,7 +63,7 @@ function ncsa_combined(){
5863

5964
echo -e "\n#GOAN_NCSA_COMBINED_LOG_FILES" >> ${goan_config}
6065
if [[ -d "${goan_log_path}" ]]; then
61-
66+
6267
echo -e "\n\tAdding proxy logs..."
6368
IFS=$'\n'
6469

@@ -106,7 +111,7 @@ function ncsa_combined(){
106111
echo -e "\nSKIP ARCHIVED LOGS"
107112
echo "-------------------------------"
108113
echo "FEATURE NOT AVAILABLE FOR NCSA_COMBINED"
109-
114+
110115
#write out loading page
111116
echo "<!doctype html><html><head>" > ${nginx_html}
112117
echo "<title>GOAN - ${goan_version}</title>" >> ${nginx_html}

resources/scripts/logs/npm.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ function npm_goaccess_config(){
3838
echo "port 7890" >> ${goan_config}
3939
echo "real-time-html true" >> ${goan_config}
4040
echo "output ${nginx_html}" >> ${goan_config}
41+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
42+
echo -e "\n\tENABLING NPM INSTANCE GOACCESS BROWSERS LIST"
43+
browsers_file="/goaccess-config/browsers.list"
44+
echo "browsers-file ${browsers_file}" >> ${goan_config}
45+
fi
4146
}
4247

4348
function npm(){
@@ -57,7 +62,7 @@ function npm(){
5762

5863
echo -e "\n#GOAN_NPM_PROXY_FILES" >> ${goan_config}
5964
if [[ -d "${goan_log_path}" ]]; then
60-
65+
6166
echo -e "\n\tAdding proxy logs..."
6267
IFS=$'\n'
6368
for file in $(find "${goan_log_path}" -name 'proxy*host-*_access.log' ! -name "*_error.log");
@@ -100,7 +105,7 @@ function npm(){
100105
goan_archive_detail_log_count=0
101106

102107
if [ $goan_archive_log_count != 0 ]
103-
then
108+
then
104109
echo -e "\n\tAdding proxy archive logs..."
105110

106111
IFS=$'\n'
@@ -138,7 +143,7 @@ function npm(){
138143
unset IFS
139144

140145
echo -e "\n\tAdded (${goan_archive_detail_log_count}) proxy archived logs from ${goan_log_path}..."
141-
146+
142147
else
143148
echo -e "\n\tNo archived logs found at ${goan_log_path}..."
144149
fi
@@ -168,4 +173,4 @@ function npm(){
168173
else
169174
/goaccess/goaccess --num-tests=0 --no-global-config --config-file=${goan_config} &
170175
fi
171-
}
176+
}

resources/scripts/logs/npm_error.sh

Lines changed: 165 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ function npm_error_init(){
88

99
if [[ -f ${goan_config} ]]; then
1010
rm ${goan_config}
11-
else
1211
mkdir -p "/goaccess-config/error/"
1312
cp /goaccess-config/goaccess.conf.bak ${goan_config}
1413
fi
@@ -157,3 +156,168 @@ function npm_error(){
157156
/goaccess/goaccess --no-global-config --config-file=${goan_config} &
158157
fi
159158
}
159+
160+
#!/bin/bash
161+
function npm_error_init(){
162+
goan_config="/goaccess-config/error/goaccess.conf"
163+
nginx_html="/var/www/html/error/index.html"
164+
html_config="/var/www/html/error/goaccess_conf.html"
165+
archive_log="/goaccess-config/error/archive.log"
166+
active_log="/goaccess-config/error/active.log"
167+
168+
if [[ -f ${goan_config} ]]; then
169+
rm ${goan_config}
170+
else
171+
mkdir -p "/goaccess-config/error/"
172+
cp /goaccess-config/goaccess.conf.bak ${goan_config}
173+
fi
174+
if [[ -f ${nginx_html} ]]; then
175+
rm ${nginx_html}
176+
else
177+
mkdir -p "/var/www/html/error/"
178+
touch ${nginx_html}
179+
fi
180+
if [[ -f ${html_config} ]]; then
181+
rm ${html_config}
182+
fi
183+
184+
echo -n "" > ${archive_log}
185+
echo -n "" > ${active_log}
186+
}
187+
188+
function npm_error_goaccess_config(){
189+
echo -e "\n\n\n" >> ${goan_config}
190+
echo "######################################" >> ${goan_config}
191+
echo "# ${goan_version}" >> ${goan_config}
192+
echo "# GOAN_NPM_ERROR_CONFIG" >> ${goan_config}
193+
echo "######################################" >> ${goan_config}
194+
echo "time-format %T" >> ${goan_config}
195+
echo "date-format %Y/%m/%d" >> ${goan_config}
196+
echo "log_format %d %t %^: %v, %^: %h, %^ %v %^"%r" %^" >> ${goan_config}
197+
echo "port 7892" >> ${goan_config}
198+
echo "real-time-html true" >> ${goan_config}
199+
echo "output ${nginx_html}" >> ${goan_config}
200+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
201+
echo -e "\n\tENABLING NPM ERROR INSTANCE GOACCESS BROWSERS LIST"
202+
browsers_file="/goaccess-config/browsers.list"
203+
echo "browsers-file ${browsers_file}" >> ${goan_config}
204+
fi
205+
}
206+
207+
function npm_error(){
208+
npm_error_init
209+
npm_error_goaccess_config
210+
211+
echo -e "\nLOADING ERROR LOGS"
212+
echo "-------------------------------"
213+
214+
echo $'\n' >> ${goan_config}
215+
echo "#GOAN_ERROR_LOG_FILES" >> ${goan_config}
216+
echo "log-file ${archive_log}" >> ${goan_config}
217+
echo "log-file ${active_log}" >> ${goan_config}
218+
219+
goan_log_count=0
220+
goan_archive_log_count=0
221+
222+
echo -e "\n#GOAN_NPM_ERROR_FILES" >> ${goan_config}
223+
if [[ -d "${goan_log_path}" ]]; then
224+
225+
echo -e "\n\tAdding error logs..."
226+
IFS=$'\n'
227+
for file in $(find "${goan_log_path}" -name '*_error.log');
228+
do
229+
if [ -f $file ]
230+
then
231+
if [ -r $file ] && R="Read = yes" || R="Read = No"
232+
then
233+
number_of_lines=`wc -l < $file`
234+
how_many_lines_contain_warn=`grep -c "\[warn\]" $file`
235+
236+
if [ $how_many_lines_contain_warn == $number_of_lines ] && [ $number_of_lines != 0 ]
237+
then
238+
echo -e "\t${file} has inconsistent log types, skipping"
239+
else
240+
echo "log-file ${file}" >> ${goan_config}
241+
goan_log_count=$((goan_log_count+1))
242+
echo -ne ' \t '
243+
echo "Filename: $file | $R"
244+
fi
245+
else
246+
echo -ne ' \t '
247+
echo "Filename: $file | $R"
248+
fi
249+
else
250+
echo -ne ' \t '
251+
echo "Filename: $file | Not a file"
252+
fi
253+
done
254+
unset IFS
255+
256+
echo -e "\tFound (${goan_log_count}) error logs..."
257+
258+
echo -e "\n\tSKIP ARCHIVED LOGS"
259+
echo -e "\t-------------------------------"
260+
if [[ "${SKIP_ARCHIVED_LOGS}" == "True" ]]
261+
then
262+
echo -e "\tTRUE"
263+
else
264+
echo -e "\tFALSE"
265+
goan_archive_log_count=`ls -1 ${goan_log_path}/*_error.log*.gz 2> /dev/null | wc -l`
266+
267+
if [ $goan_archive_log_count != 0 ]
268+
then
269+
echo -e "\n\tAdding error archive logs..."
270+
271+
IFS=$'\n'
272+
for file in $(find "${goan_log_path}" -name '*_error.log*.gz');
273+
do
274+
if [ -f $file ]
275+
then
276+
if [ -r $file ] && R="Read = yes" || R="Read = No"
277+
then
278+
echo -ne ' \t '
279+
echo "Filename: $file | $R"
280+
else
281+
echo -ne ' \t '
282+
echo "Filename: $file | $R"
283+
fi
284+
else
285+
echo -ne ' \t '
286+
echo "Filename: $file | Not a file"
287+
fi
288+
done
289+
unset IFS
290+
291+
echo -e "\tAdded (${goan_archive_log_count}) error archived logs from ${goan_log_path}..."
292+
zcat -f ${goan_log_path}/*_error.log*.gz > ${archive_log}
293+
sed -e '/\[warn\]/d' -i ${archive_log}
294+
else
295+
echo -e "\tNo error archived logs found at ${goan_log_path}..."
296+
fi
297+
fi
298+
299+
else
300+
echo "Problem loading directory (check directory or permissions)... ${goan_log_path}"
301+
fi
302+
303+
#additonal config settings
304+
exclude_ips ${goan_config}
305+
set_geoip_database ${goan_config}
306+
debug ${goan_config} ${html_config}
307+
308+
#write out loading page
309+
echo "<!doctype html><html><head>" > ${nginx_html}
310+
echo "<title>GOAN - ${goan_version}</title>" >> ${nginx_html}
311+
echo "<meta http-equiv=\"refresh\" content=\"1\" >" >> ${nginx_html}
312+
echo "<style>body {font-family: Arial, sans-serif;}</style>" >> ${nginx_html}
313+
echo "</head><body><p><b>${goan_version}</b><br/><br/>loading... <br/><br/>" >> ${nginx_html}
314+
echo "Logs processing: $(($goan_log_count + $goan_archive_log_count)) (might take some time depending on the number of files to parse)" >> ${nginx_html}
315+
echo "<br/></p></body></html>" >> ${nginx_html}
316+
317+
echo -e "\nRUN NPM ERROR GOACCESS"
318+
if [[ "${DEBUG}" == "True" ]]; then
319+
/goaccess-debug/goaccess --debug-file=${goaccess_debug_file} --invalid-requests=${goaccess_invalid_file} --no-global-config --config-file=${goan_config} &
320+
else
321+
/goaccess/goaccess --no-global-config --config-file=${goan_config} &
322+
fi
323+
}

resources/scripts/logs/npm_redirection.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ function npm_redirect_goaccess_config(){
3838
echo "port 7891" >> ${goan_config}
3939
echo "real-time-html true" >> ${goan_config}
4040
echo "output ${nginx_html}" >> ${goan_config}
41+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
42+
echo -e "\n\tENABLING NPM REDIRECTION INSTANCE GOACCESS BROWSERS LIST"
43+
browsers_file="/goaccess-config/browsers.list"
44+
echo "browsers-file ${browsers_file}" >> ${goan_config}
45+
fi
4146
}
4247

4348
function npm_redirect(){
@@ -57,7 +62,7 @@ function npm_redirect(){
5762

5863
echo -e "\n#GOAN_NPM_REDIRECT_FALLBACK_DEAD_FILES" >> ${goan_config}
5964
if [[ -d "${goan_log_path}" ]]; then
60-
65+
6166
echo -e "\n\tAdding redirection/fallback/dead logs..."
6267
IFS=$'\n'
6368
for file in $(find "${goan_log_path}" \( -name 'redirection*host-*.log' -o -name 'fallback_access.log' -o -name 'dead-host*.log' \) ! -name "*_error.log*");
@@ -81,9 +86,9 @@ function npm_redirect(){
8186
echo -e "\tFALSE"
8287
goan_archive_log_count=$(find "${goan_log_path}" -type f \( -name 'redirection*host-*.log*.gz' -o -name 'fallback_access.log*.gz' -o -name 'dead-host*.log*.gz' \) ! -name "*_error.log*" | wc -l)
8388
goan_archive_detail_log_count=0
84-
89+
8590
if [ $goan_archive_log_count != 0 ]
86-
then
91+
then
8792
echo -e "\n\tAdding redirection/fallback/dead archive logs..."
8893

8994
IFS=$'\n'
@@ -98,7 +103,7 @@ function npm_redirect(){
98103
unset IFS
99104

100105
echo -e "\n\tAdded (${goan_archive_detail_log_count}) redirection/fallback/dead archived logs from ${goan_log_path}..."
101-
106+
102107
else
103108
echo -e "\tNo redirection/fallback archived logs found at ${goan_log_path}..."
104109
fi

0 commit comments

Comments
 (0)