aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-08 16:31:05 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-08 16:31:05 +0100
commit0facadb8d6c96326bec6a2d7f41cc67987c66899 (patch)
tree4359f87630a911bd20500e0143b9a12ea8e53223
parent56991aa7d6fba4cf1afd0e6d7f770f1272ebbf54 (diff)
downloadNix-0facadb8d6c96326bec6a2d7f41cc67987c66899.tar.gz
Nix-0facadb8d6c96326bec6a2d7f41cc67987c66899.tar.zst
Nix-0facadb8d6c96326bec6a2d7f41cc67987c66899.zip
Rewrite stats generation script
-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?