summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2018-11-10 12:20:34 +0000
committerintrigeri <intrigeri@boum.org>2018-11-10 12:20:34 +0000
commit21a92c65eaad74316348562676459376454ceaa9 (patch)
tree93913b4b0c46ab9113b6f09d92ee61a96f7be0d5
parent374233457ca0da19e8adbdc935ad49df13d571b0 (diff)
Website: send stats every month to tails@ (refs: #14588)
-rw-r--r--files/website/tails-website-last-month-stats36
-rw-r--r--manifests/website.pp8
-rw-r--r--manifests/website/webserver/instance.pp14
3 files changed, 58 insertions, 0 deletions
diff --git a/files/website/tails-website-last-month-stats b/files/website/tails-website-last-month-stats
new file mode 100644
index 0000000..153a95f
--- /dev/null
+++ b/files/website/tails-website-last-month-stats
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+set -e
+set -u
+
+LOGS_DIR="$1"
+
+export LC_ALL=C
+
+cd "$LOGS_DIR"
+
+LAST_MONTH=$(date --date='last month' '+%B')
+LAST_MONTH_ABBR=$(date --date='last month' '+%b')
+
+LOG_FILES=
+for f in $(seq 90 -1 2); do
+ log_file="access.log.$f.gz"
+ if [ -e "$log_file" ]; then
+ LOG_FILES="${LOG_FILES} ${log_file}"
+ fi
+done
+for log_file in access.log.1 access.log ; do
+ if [ -e "$log_file" ]; then
+ LOG_FILES="${LOG_FILES} ${log_file}"
+ fi
+done
+
+echo -n "Boots in $LAST_MONTH: "
+zgrep --count -E \
+ "/${LAST_MONTH_ABBR}/.*\"GET /security/index\.[a-z]{2}\.atom HTTP/[0-9]\.[0-9]\" 200 [0-9]+ \"-\" \"(-|libwww-perl/)" \
+ $LOG_FILES
+
+echo -n "Downloads of the OpenPGP signature in $LAST_MONTH: "
+zgrep --count -E \
+ "/${LAST_MONTH_ABBR}/.*\"GET /torrents/files/tails-[-a-z0-9~.]\+\.iso\.sig .* 200 [0-9]\+" \
+ $LOG_FILES
diff --git a/manifests/website.pp b/manifests/website.pp
index a384140..77aec4f 100644
--- a/manifests/website.pp
+++ b/manifests/website.pp
@@ -149,4 +149,12 @@ class tails::website (
email_recipient => 'intrigeri@boum.org',
}
+ file { '/usr/local/bin/tails-website-last-month-stats':
+ ensure => $ensure,
+ source => 'puppet:///modules/tails/website/tails-website-last-month-stats',
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ }
+
}
diff --git a/manifests/website/webserver/instance.pp b/manifests/website/webserver/instance.pp
index 90866f6..025dd6b 100644
--- a/manifests/website/webserver/instance.pp
+++ b/manifests/website/webserver/instance.pp
@@ -61,4 +61,18 @@ define tails::website::webserver::instance (
if $ssl {
tails::letsencrypt::certonly { $public_hostname: }
}
+
+ cron { "tails-website-email-last-month-stats ${public_hostname}":
+ user => 'www-data',
+ monthday => '2',
+ hour => '17',
+ minute => '57',
+ command => "/usr/local/bin/tails-website-last-month-stats '${log_dir}'",
+ environment => [ 'MAILTO=tails@boum.org' ],
+ require => File[
+ $log_dir,
+ '/usr/local/bin/tails-website-last-month-stats',
+ ],
+ }
+
}