DEV Community

Discussion on: 5 Web Discoveries Which Are Pretty Useful

 
thojest profile image
thojest • Edited

Here you go. This is the non-realtime version (Browser does not update dashboard in realtime, but this is also possible. Ask if interested). It will collect all log files, copy to my machine into a single log file

#!/bin/bash
rm html/index.html #remove old files
rm log/nginx.log # remove old files
touch html/index.html # create empty new html

# open ssh connection to host in terminal mode
# and tail all logfiles from the server
#
# now grep through the whole thing and exclude log entries which
# fulfill some pattern defined in excludelist.txt
# (useful for excluding dates, IPs, non-interesting routes,  ...)
#
# 
ssh -t $(whoami)@<HOSTNAME> tail -q -n +0 /var/log/nginx/access* | grep -v -f excludelist.txt > log/nginx.log

#open the created html file (still empty) in browser
google-chrome html/index.html &
# now use goaccess on our collected log file and use some config
# file which describes how to draw the dashboard
goaccess --no-global-config --config-file=./data/goaccess.conf --log-file=log/nginx.log

Press F5 in browser to reload the created html file.
There is much room for optimization :) but it just works and I am happy with it :)