Skip to content

Commit 723c4ef

Browse files
v1.1.5 (#84)
* v1.1.5 - NCSA COMBINED ADDITION added generic NCSA PROFILE updated parameter name and readme
1 parent 98a8d4e commit 723c4ef

File tree

3 files changed

+142
-1
lines changed

3 files changed

+142
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ goaccess:
8585
| `-e BASIC_AUTH_USERNAME=user` | (Optional) Requires BASIC_AUTH to bet set to True. Username for basic authentication. |
8686
| `-e BASIC_AUTH_PASSWORD=pass` | (Optional) Requires BASIC_AUTH to bet set to True. Password for basic authentication. |
8787
| `-e EXCLUDE_IPS=` | (Optional) IP Addresses or range of IPs delimited by comma refer to https://goaccess.io/man. For example: 192.168.0.1-192.168.0.100 or 127.0.0.1,192.168.0.1-192.168.0.100 |
88-
| `-e LOG_TYPE=` | (Optional) By default the configuration will be set to read NPM logs. Options are: CUSTOM, NPM, NPM+R, TRAEFIK. More information below.|
88+
| `-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.|
89+
| `-e LOG_TYPE_FILE_PATTERN=` | (Optional) Only to be used with LOG_TYPE=NCSA_COMBINED. 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! |
8990

9091
# **Additional environment information**
9192
` -e LOG_TYPE=`
@@ -118,6 +119,11 @@ goaccess:
118119
- SKIP_ARCHIVED_LOGS
119120
- the following file(s) are read and parsed.
120121
- access.log
122+
- NCSA_COMBINED
123+
- environment parameters that will not work and will be ignored
124+
- SKIP_ARCHIVED_LOGS
125+
- by default the following file(s) are read and parsed.
126+
- *.log
121127

122128

123129
# **LOG FORMATS**
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/bash
2+
function ncsa_combined_init(){
3+
goan_config="/goaccess-config/goaccess.conf"
4+
nginx_html="/var/www/html/index.html"
5+
html_config="/var/www/html/goaccess_conf.html"
6+
archive_log="/goaccess-config/archive.log"
7+
active_log="/goaccess-config/active.log"
8+
9+
if [[ -f ${goan_config} ]]; then
10+
rm ${goan_config}
11+
else
12+
mkdir -p "/goaccess-config/"
13+
cp /goaccess-config/goaccess.conf.bak ${goan_config}
14+
fi
15+
if [[ -f ${nginx_html} ]]; then
16+
rm ${nginx_html}
17+
else
18+
mkdir -p "/var/www/html/"
19+
touch ${nginx_html}
20+
fi
21+
if [[ -f ${html_config} ]]; then
22+
rm ${html_config}
23+
fi
24+
if [[ -f "$archive_log" ]]; then
25+
rm ${archive_log}
26+
else
27+
touch ${archive_log}
28+
fi
29+
if [[ -f "$active_log" ]]; then
30+
rm ${active_log}
31+
else
32+
touch ${active_log}
33+
fi
34+
}
35+
36+
function ncsa_combined_goaccess_config(){
37+
echo -e "\n\n\n" >> ${goan_config}
38+
echo "######################################" >> ${goan_config}
39+
echo "# ${goan_version}" >> ${goan_config}
40+
echo "# GOAN_PROXY_CONFIG" >> ${goan_config}
41+
echo "######################################" >> ${goan_config}
42+
echo "time-format %T" >> ${goan_config}
43+
echo "date-format %d/%b/%Y" >> ${goan_config}
44+
#echo "log-format [%d:%t %^] %^ %s %^ %^ %m %^ %v \"%U\" [%^ %h] [%^ %b] %^\"%u\" \"%R\"" >> ${goan_config}
45+
echo "log-format %h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"" >> ${goan_config}
46+
echo "port 7890" >> ${goan_config}
47+
echo "real-time-html true" >> ${goan_config}
48+
echo "output ${nginx_html}" >> ${goan_config}
49+
}
50+
51+
function ncsa_combined(){
52+
ncsa_combined_init
53+
ncsa_combined_goaccess_config
54+
55+
echo -e "\nLOADING NCSA_COMBINED LOGS"
56+
echo "-------------------------------"
57+
58+
echo $'\n' >> ${goan_config}
59+
echo "#GOAN_DEFAULT_LOG_FILES" >> ${goan_config}
60+
echo "log-file ${archive_log}" >> ${goan_config}
61+
echo "log-file ${active_log}" >> ${goan_config}
62+
63+
goan_log_count=0
64+
goan_archive_log_count=0
65+
66+
echo -e "\n#GOAN_NCSA_COMBINED_LOG_FILES" >> ${goan_config}
67+
if [[ -d "${goan_log_path}" && -x "${goan_log_path}" ]]; then
68+
69+
echo -e "\n\tAdding proxy logs..."
70+
IFS=$'\n'
71+
72+
if [[ -z "${LOG_TYPE_FILE_PATTERN}" ]]; then
73+
LOG_TYPE_FILE_PATTERN="*.log"
74+
fi
75+
76+
for file in $(find "${goan_log_path}" -name "${LOG_TYPE_FILE_PATTERN}");
77+
do
78+
if [ -f $file ]
79+
then
80+
if [ -r $file ] && R="Read = yes" || R="Read = No"
81+
then
82+
echo "log-file ${file}" >> ${goan_config}
83+
goan_log_count=$((goan_log_count+1))
84+
echo -ne ' \t '
85+
echo "Filename: $file | $R"
86+
else
87+
echo -ne ' \t '
88+
echo "Filename: $file | $R"
89+
fi
90+
else
91+
echo -ne ' \t '
92+
echo "Filename: $file | Not a file"
93+
fi
94+
done
95+
unset IFS
96+
else
97+
echo "Problem loading directory (check directory or permissions)... ${goan_log_path}"
98+
fi
99+
100+
if [ $goan_log_count != 0 ]
101+
then
102+
echo "Found (${goan_log_count}) proxy logs..."
103+
else
104+
echo "No access.log found. Creating an empty log file..."
105+
touch "${goan_log_path}/access.log"
106+
fi
107+
108+
#additonal config settings
109+
exclude_ips ${goan_config}
110+
debug ${goan_config} ${html_config}
111+
set_geoip_database ${goan_config}
112+
113+
echo -e "\nSKIP ARCHIVED LOGS"
114+
echo "-------------------------------"
115+
echo "FEATURE NOT AVAILABLE FOR NCSA_COMBINED"
116+
117+
#write out loading page
118+
echo "<!doctype html><html><head>" > ${nginx_html}
119+
echo "<title>GOAN - ${goan_version}</title>" >> ${nginx_html}
120+
echo "<meta http-equiv=\"refresh\" content=\"1\" >" >> ${nginx_html}
121+
echo "<style>body {font-family: Arial, sans-serif;}</style>" >> ${nginx_html}
122+
echo "</head><body><p><b>${goan_version}</b><br/><br/>loading... <br/><br/>" >> ${nginx_html}
123+
echo "Logs processing: $(($goan_log_count)) (might take some time depending on the number of files to parse)" >> ${nginx_html}
124+
echo "<br/></p></body></html>" >> ${nginx_html}
125+
126+
echo -e "\nRUN NCSA_COMBINED GOACCESS"
127+
if [[ "${DEBUG}" == "True" ]]; then
128+
/goaccess-debug/goaccess --debug-file=${goaccess_debug_file} --invalid-requests=${goaccess_invalid_file} --no-global-config --config-file=${goan_config} &
129+
else
130+
/goaccess/goaccess --no-global-config --config-file=${goan_config} &
131+
fi
132+
}

resources/scripts/start.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source $(dirname "$0")/logs/npm.sh
55
source $(dirname "$0")/logs/npm_redirection.sh
66
source $(dirname "$0")/logs/traefik.sh
77
source $(dirname "$0")/logs/custom.sh
8+
source $(dirname "$0")/logs/ncsa_combined.sh
89

910
goan_version="GOAN v1.1.4"
1011
goan_log_path="/opt/log"
@@ -37,6 +38,8 @@ if [[ -z "${LOG_TYPE}" || "${LOG_TYPE}" == "NPM" || "${LOG_TYPE}" == "NPM+R" ]];
3738
npm
3839
elif [[ "${LOG_TYPE}" == "TRAEFIK" ]]; then
3940
traefik
41+
elif [[ "${LOG_TYPE}" == "NCSA_COMBINED" ]]; then
42+
ncsa_combined
4043
elif [[ "${LOG_TYPE}" == "CUSTOM" ]]; then
4144
custom
4245
fi

0 commit comments

Comments
 (0)