diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-11 10:23:33 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-11 10:23:33 +0200 |
commit | 9eae2b47b7b315b05a0e010f3003bd875685e260 (patch) | |
tree | 43c9cfeb2db393f64743daa4ec87e0fe78ab772e /nixops/modules/websites/commons | |
parent | b7ee93fcdee2509cd4c0caec2c5c59ccff5bab2c (diff) | |
download | Nix-9eae2b47b7b315b05a0e010f3003bd875685e260.tar.gz Nix-9eae2b47b7b315b05a0e010f3003bd875685e260.tar.zst Nix-9eae2b47b7b315b05a0e010f3003bd875685e260.zip |
Move webstats outside of nixops
Diffstat (limited to 'nixops/modules/websites/commons')
-rw-r--r-- | nixops/modules/websites/commons/goaccess.conf | 99 | ||||
-rw-r--r-- | nixops/modules/websites/commons/stats.nix | 69 |
2 files changed, 0 insertions, 168 deletions
diff --git a/nixops/modules/websites/commons/goaccess.conf b/nixops/modules/websites/commons/goaccess.conf deleted file mode 100644 index 4918988..0000000 --- a/nixops/modules/websites/commons/goaccess.conf +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | time-format %H:%M:%S | ||
2 | date-format %d/%b/%Y | ||
3 | |||
4 | #sur immae.eu | ||
5 | #log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" $^ | ||
6 | |||
7 | log-format VCOMBINED | ||
8 | #= %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" | ||
9 | |||
10 | html-prefs {"theme":"bright","layout":"vertical"} | ||
11 | |||
12 | exclude-ip 188.165.209.148 | ||
13 | exclude-ip 178.33.252.96 | ||
14 | exclude-ip 2001:41d0:2:9c94::1 | ||
15 | exclude-ip 2001:41d0:2:9c94:: | ||
16 | exclude-ip 176.9.151.89 | ||
17 | exclude-ip 2a01:4f8:160:3445:: | ||
18 | exclude-ip 82.255.56.72 | ||
19 | |||
20 | no-query-string true | ||
21 | |||
22 | keep-db-files true | ||
23 | load-from-disk true | ||
24 | db-path @dbPath@ | ||
25 | |||
26 | ignore-panel REFERRERS | ||
27 | ignore-panel KEYPHRASES | ||
28 | |||
29 | static-file .css | ||
30 | static-file .js | ||
31 | static-file .jpg | ||
32 | static-file .png | ||
33 | static-file .gif | ||
34 | static-file .ico | ||
35 | static-file .jpeg | ||
36 | static-file .pdf | ||
37 | static-file .csv | ||
38 | static-file .mpeg | ||
39 | static-file .mpg | ||
40 | static-file .swf | ||
41 | static-file .woff | ||
42 | static-file .woff2 | ||
43 | static-file .xls | ||
44 | static-file .xlsx | ||
45 | static-file .doc | ||
46 | static-file .docx | ||
47 | static-file .ppt | ||
48 | static-file .pptx | ||
49 | static-file .txt | ||
50 | static-file .zip | ||
51 | static-file .ogg | ||
52 | static-file .mp3 | ||
53 | static-file .mp4 | ||
54 | static-file .exe | ||
55 | static-file .iso | ||
56 | static-file .gz | ||
57 | static-file .rar | ||
58 | static-file .svg | ||
59 | static-file .bmp | ||
60 | static-file .tar | ||
61 | static-file .tgz | ||
62 | static-file .tiff | ||
63 | static-file .tif | ||
64 | static-file .ttf | ||
65 | static-file .flv | ||
66 | #static-file .less | ||
67 | #static-file .ac3 | ||
68 | #static-file .avi | ||
69 | #static-file .bz2 | ||
70 | #static-file .class | ||
71 | #static-file .cue | ||
72 | #static-file .dae | ||
73 | #static-file .dat | ||
74 | #static-file .dts | ||
75 | #static-file .ejs | ||
76 | #static-file .eot | ||
77 | #static-file .eps | ||
78 | #static-file .img | ||
79 | #static-file .jar | ||
80 | #static-file .map | ||
81 | #static-file .mid | ||
82 | #static-file .midi | ||
83 | #static-file .ogv | ||
84 | #static-file .webm | ||
85 | #static-file .mkv | ||
86 | #static-file .odp | ||
87 | #static-file .ods | ||
88 | #static-file .odt | ||
89 | #static-file .otf | ||
90 | #static-file .pict | ||
91 | #static-file .pls | ||
92 | #static-file .ps | ||
93 | #static-file .qt | ||
94 | #static-file .rm | ||
95 | #static-file .svgz | ||
96 | #static-file .wav | ||
97 | #static-file .webp | ||
98 | |||
99 | |||
diff --git a/nixops/modules/websites/commons/stats.nix b/nixops/modules/websites/commons/stats.nix deleted file mode 100644 index 73595f1..0000000 --- a/nixops/modules/websites/commons/stats.nix +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | { lib, pkgs, config, mylibs, ... }: | ||
2 | let | ||
3 | cfg = config.services.myWebsites.commons.stats; | ||
4 | in { | ||
5 | options = { | ||
6 | services.myWebsites.commons.stats = { | ||
7 | enable = lib.mkEnableOption "enable statistics"; | ||
8 | sites = lib.mkOption { | ||
9 | type = lib.types.listOf (lib.types.submodule { | ||
10 | options = { | ||
11 | conf = lib.mkOption { | ||
12 | type = lib.types.nullOr lib.types.path; | ||
13 | default = null; | ||
14 | }; | ||
15 | name = lib.mkOption { type = lib.types.string; }; | ||
16 | }; | ||
17 | }); | ||
18 | default = []; | ||
19 | description = "Sites to generate stats"; | ||
20 | }; | ||
21 | }; | ||
22 | }; | ||
23 | |||
24 | config = lib.mkIf cfg.enable { | ||
25 | users.users.root.packages = [ | ||
26 | pkgs.goaccess | ||
27 | ]; | ||
28 | |||
29 | services.cron = { | ||
30 | enable = true; | ||
31 | systemCronJobs = let | ||
32 | stats = domain: conf: let | ||
33 | config = if builtins.isNull conf | ||
34 | then pkgs.runCommand "goaccess.conf" { | ||
35 | dbPath = "/var/lib/goaccess/${domain}"; | ||
36 | } "substituteAll ${./goaccess.conf} $out" | ||
37 | else conf; | ||
38 | d = pkgs.writeScriptBin "stats-${domain}" '' | ||
39 | #!${pkgs.stdenv.shell} | ||
40 | set -e | ||
41 | shopt -s nullglob | ||
42 | date_regex=$(LC_ALL=C date -d yesterday +'%d\/%b\/%Y') | ||
43 | TMPFILE=$(mktemp) | ||
44 | trap "rm -f $TMPFILE" EXIT | ||
45 | |||
46 | cat /var/log/httpd/access_log-${domain} | sed -n "/\\[$date_regex/ p" > $TMPFILE | ||
47 | for i in /var/log/httpd/access_log-${domain}*.gz; do | ||
48 | zcat "$i" | sed -n "/\\[$date_regex/ p" >> $TMPFILE | ||
49 | done | ||
50 | ${pkgs.goaccess}/bin/goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${config} | ||
51 | ''; | ||
52 | in "${d}/bin/stats-${domain}"; | ||
53 | allStats = sites: pkgs.writeScript "stats" '' | ||
54 | #!${pkgs.stdenv.shell} | ||
55 | |||
56 | ${builtins.concatStringsSep "\n" (map (v: stats v.name v.conf) sites)} | ||
57 | ''; | ||
58 | in | ||
59 | [ | ||
60 | "5 0 * * * root ${allStats cfg.sites}" | ||
61 | ]; | ||
62 | }; | ||
63 | |||
64 | system.activationScripts.goaccess = '' | ||
65 | mkdir -p /var/lib/goaccess | ||
66 | '' + | ||
67 | builtins.concatStringsSep "\n" (map (v: "mkdir -p /var/lib/goaccess/${v.name}") cfg.sites); | ||
68 | }; | ||
69 | } | ||