From 5b839475df25daf94ae676c6449ca495a2b75b4f Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Mon, 13 Jul 2015 19:18:14 +0000 Subject: [PATCH] add gather stats cron job to people for ticket 4822 --- roles/people/files/grab-daily-logs.cron | 5 ++++ roles/people/files/grab-daily-logs.sh | 40 +++++++++++++++++++++++++ roles/people/tasks/main.yml | 10 +++++++ 3 files changed, 55 insertions(+) create mode 100644 roles/people/files/grab-daily-logs.cron create mode 100755 roles/people/files/grab-daily-logs.sh diff --git a/roles/people/files/grab-daily-logs.cron b/roles/people/files/grab-daily-logs.cron new file mode 100644 index 0000000000..cd4da69997 --- /dev/null +++ b/roles/people/files/grab-daily-logs.cron @@ -0,0 +1,5 @@ +#!/bin/bash +# openstack/rdo +bash /usr/local/bin/grab-daily-logs.sh /repos/openstack/ rdo +# aarch64 image +bash /usr/local/bin/grab-daily-logs.sh F21-20140407-foundation-v8.tar.xz aarch64-stats diff --git a/roles/people/files/grab-daily-logs.sh b/roles/people/files/grab-daily-logs.sh new file mode 100755 index 0000000000..76f182ab24 --- /dev/null +++ b/roles/people/files/grab-daily-logs.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# skvidal - 2013-06-25 +# takes 2 args: grep_search_string subdir_to_write_to +# ex: bash grab-daily-logs.sh /repos/openstack/ rdo + + +logpath='/var/log/httpd/' +basedest="/srv/people/site/accesslogs/" +logfn='fedorapeople.org-access.log' +search="$1" +destpath="$basedest/$2" +dstamp=`date -d yesterday +%Y-%m-%d` + +# basedest +if [ ! -d $basedest ]; then + mkdir -p $basedest + chown apache.apache $basedest + chmod 770 $basedest +fi + +#make sure there is an index.html up one so you can't find it +if [ ! -f $basedest/index.html ]; then + echo "nothing to see" > $basedest/index.html + chmod 664 $basedest/index.html +fi + +#make the destpath +if [ ! -d $destpath ]; then + mkdir -p $destpath + chown apache.apache $destpath + chmod 770 $destpath +fi + +# grab the logs +grep $search $logpath/${logfn}-${dstamp} >> ${destpath}/${dstamp}.log +chown apache.apache $destpath/${dstamp}.log +chmod 640 $destpath/${dstamp}.log + +# clean up the old logs +/usr/sbin/tmpwatch -f 720 -m $destpath diff --git a/roles/people/tasks/main.yml b/roles/people/tasks/main.yml index 400b1d0216..bdd480f8ca 100644 --- a/roles/people/tasks/main.yml +++ b/roles/people/tasks/main.yml @@ -176,3 +176,13 @@ file: state=link src=/project dest=/srv/groups tags: - people + +- name: setup script to grab download stats for some groups. + copy: src=grab-daily-logs.sh dest=/usr/local/bin/grab-daily-logs.sh mode=0755 + tags: + - people + +- name: setup cron job to gather download stats + copy: src=grab-daily-logs.cron dest=/etc/cron.d/grab-daily-logs mode=0644 + tags: + - people