Pyoungmeister has submitted this change and it was merged.

Change subject: stat1 cron job that emails out aggregate pageviews
......................................................................


stat1 cron job that emails out aggregate pageviews

Change-Id: Id36bc8a6de648c91fa594469298b49a04a4ddcd7
---
M manifests/misc/statistics.pp
M manifests/site.pp
A templates/misc/email-blog-pageviews.erb
3 files changed, 37 insertions(+), 0 deletions(-)

Approvals:
  Pyoungmeister: Verified; Looks good to me, approved



diff --git a/manifests/misc/statistics.pp b/manifests/misc/statistics.pp
index 0ced104..918725e 100644
--- a/manifests/misc/statistics.pp
+++ b/manifests/misc/statistics.pp
@@ -669,3 +669,31 @@
                minute  => 0,
        }
 }
+
+
+# Class: misc::statistics::cron_blog_pageviews
+#
+# Sets up daily cron jobs to run a script which
+# groups blog pageviews by url and emails them
+class misc::statistics::cron_blog_pageviews {
+       file {
+               "/usr/local/bin/blog.sh":
+                       mode    => 0755,
+                       content => template("misc/email-blog-pageviews.erb");
+               "/home/dandreescu/blog_cron_output":
+                       ensure => "directory",
+                       owner  => "dandreescu",
+                       group  => "wikidev",
+                       mode   => 0755;
+       }
+
+       # Create a daily cron job to run the blog script
+       # This requires that the $misc::statistics::user::username
+       # user is installed on the source host.
+       cron { "rsync_${name}_logs":
+               command => "/usr/local/bin/blog.sh",
+               user    => "$misc::statistics::user::username",
+               hour    => 8,
+               minute  => 0,
+       }
+}
diff --git a/manifests/site.pp b/manifests/site.pp
index 4dc3fc5..436f6c7 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -2369,6 +2369,8 @@
 
 
        sudo_user { "otto": privileges => ['ALL = NOPASSWD: ALL'] }
+
+       include misc::statistics::cron_blog_pageviews
 }
 
 node "stat1001.wikimedia.org" {
diff --git a/templates/misc/email-blog-pageviews.erb 
b/templates/misc/email-blog-pageviews.erb
new file mode 100644
index 0000000..481f660
--- /dev/null
+++ b/templates/misc/email-blog-pageviews.erb
@@ -0,0 +1,7 @@
+DATE=`date '+%Y-%m-%d'`;
+OUTPUT=/home/dandreescu/blog_cron_output/blog_$DATE.tsv
+
+mysql log -h db1047.eqiad.wmnet -p<%= 
scope.lookupvar('passwords::mysql::research::password') %>
+ -u<%= scope.lookupvar('passwords::mysql::research::user') %> -e "select 
count(event_requestUrl) as count, date(timestamp), event_requestUrl from 
WikimediaBlogVisit_5308166 where date(timestamp)=date('$DATE') group by 
event_requestUrl order by date(timestamp) desc, count desc;" > $OUTPUT
+
+cat $OUTPUT | mailx -s "Daily Blog Pageviews" [email protected]

-- 
To view, visit https://gerrit.wikimedia.org/r/54102
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id36bc8a6de648c91fa594469298b49a04a4ddcd7
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Milimetric <[email protected]>
Gerrit-Reviewer: Pyoungmeister <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to