aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--virtual/eldiron.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/virtual/eldiron.nix b/virtual/eldiron.nix
index b9dba3f..cd92b3d 100644
--- a/virtual/eldiron.nix
+++ b/virtual/eldiron.nix
@@ -661,7 +661,20 @@
661 enable = true; 661 enable = true;
662 systemCronJobs = let 662 systemCronJobs = let
663 stats = domain: conf: let 663 stats = domain: conf: let
664 d = pkgs.writeScriptBin "stats-${domain}" "${pkgs.gnused}/bin/sed -n '/\\['$(LC_ALL=C ${pkgs.coreutils}/bin/date -d yesterday +'%d\\/%b\\/%Y')'/ p' /var/log/httpd/access_log-${domain} | ${pkgs.goaccess}/bin/goaccess -o /var/lib/goaccess/${domain}/index.html -p ${conf}"; 664 d = pkgs.writeScriptBin "stats-${domain}" ''
665 #!${pkgs.stdenv.shell}
666 set -e
667 shopt -s nullglob
668 date_regex=$(LC_ALL=C date -d yesterday +'%d\/%b\/%Y')
669 TMPFILE=$(mktemp)
670 trap "rm -f $TMPFILE" EXIT
671
672 cat /var/log/httpd/access_log-${domain} | sed -n "/\\[$date_regex/ p" > $TMPFILE
673 for i in /var/log/httpd/access_log-${domain}*.gz; do
674 zcat "$i" | sed -n "/\\[$date_regex/ p" >> $TMPFILE
675 done
676 goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${conf}
677 '';
665 in "${d}/bin/stats-${domain}"; 678 in "${d}/bin/stats-${domain}";
666 # FIXME: running several goaccess simultaneously seems to be 679 # FIXME: running several goaccess simultaneously seems to be
667 # bugged? 680 # bugged?