Created
June 6, 2017 08:29
-
-
Save lucien144/9745bf1ba137ab20a67d18a6999356f3 to your computer and use it in GitHub Desktop.
GoAccess monthly reports with summary report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
START=$SECONDS | |
FILES=/var/www/vhosts/site.com/logs/access-2*.log | |
# Generate summary | |
goaccess /var/www/vhosts/site.com/logs/access.log --geoip-database /var/www/vhosts/site.com/logs/GeoIP.dat -o /var/www/vhosts/site.com/web/web/reports/summary.html | |
# Generate monthly reports | |
# -> Split logs | |
awk '{ split($4,array,"[:/]"); print > "/var/www/vhosts/site.com/logs/access-" array[3] "-" array[2] ".log" }' /var/www/vhosts/site.com/logs/access.log | |
# -> Generate montly reports | |
for f in $FILES | |
do | |
goaccess $f --geoip-database /var/www/vhosts/site.com/logs/GeoIP.dat -o "/var/www/vhosts/site.com/web/web/reports/`basename $f`.html" | |
done | |
DURATION=$(( SECONDS - start )) | |
echo "Reports generated after $DURATION seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment