Skip to content

Instantly share code, notes, and snippets.

@lucien144
Created June 6, 2017 08:29
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucien144/9745bf1ba137ab20a67d18a6999356f3 to your computer and use it in GitHub Desktop.
Save lucien144/9745bf1ba137ab20a67d18a6999356f3 to your computer and use it in GitHub Desktop.
GoAccess monthly reports with summary report
#!/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