From 8019968f0145b5d3d43042eb49882190cf2bbede Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Fri, 18 Jul 2014 18:33:57 +0000 Subject: [PATCH] Add syncHttpLogs to log01 --- roles/base/files/syncHttpLogs.sh | 96 ++++++++++++++++++++++++++++++++ roles/base/tasks/main.yml | 7 +++ 2 files changed, 103 insertions(+) create mode 100644 roles/base/files/syncHttpLogs.sh diff --git a/roles/base/files/syncHttpLogs.sh b/roles/base/files/syncHttpLogs.sh new file mode 100644 index 0000000000..5c5729a3de --- /dev/null +++ b/roles/base/files/syncHttpLogs.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +RSYNC_FLAGS='-az --no-motd' + +function syncHttpLogs { + + # in case we missed a run or two.. try to catch up the last 3 days. + for d in 1 2 3 + do + HOST=$1 + # some machines store stuff in old format. some new. + if [ "$2" = "old" ]; then + YESTERDAY=$(/bin/date -d "-$d days" +%Y-%m-%d) + else + YESTERDAY=$(/bin/date -d "-$d days" +%Y%m%d) + fi + YEAR=$(/bin/date -d "-$d days" +%Y) + MONTH=$(/bin/date -d "-$d days" +%m) + DAY=$(/bin/date -d "-$d days" +%d) + /bin/mkdir -p /var/log/hosts/$HOST/$YEAR/$MONTH/$DAY/http + cd /var/log/hosts/$HOST/$YEAR/$MONTH/$DAY/http/ + + for f in $(/usr/bin/rsync $RSYNC_FLAGS --list-only $HOST::log/httpd/*$YESTERDAY* | awk '{ print $5 }') + do + DEST=$(echo $f | /bin/sed s/-$YESTERDAY//) + /usr/bin/rsync $RSYNC_FLAGS $HOST::log/httpd/$f ./$DEST + done + done +} + +syncHttpLogs proxy01.phx2.fedoraproject.org +syncHttpLogs proxy02.vpn.fedoraproject.org +syncHttpLogs proxy03.vpn.fedoraproject.org +syncHttpLogs proxy04.vpn.fedoraproject.org +syncHttpLogs proxy06.vpn.fedoraproject.org +syncHttpLogs proxy07.vpn.fedoraproject.org +syncHttpLogs proxy08.vpn.fedoraproject.org +syncHttpLogs proxy09.vpn.fedoraproject.org +syncHttpLogs proxy01.stg.phx2.fedoraproject.org +syncHttpLogs app01.stg.phx2.fedoraproject.org +syncHttpLogs bapp02.phx2.fedoraproject.org +syncHttpLogs fas01.phx2.fedoraproject.org +syncHttpLogs fas02.phx2.fedoraproject.org +syncHttpLogs fas03.phx2.fedoraproject.org +syncHttpLogs fas01.stg.phx2.fedoraproject.org +syncHttpLogs fedocal01.phx2.fedoraproject.org +syncHttpLogs fedocal02.phx2.fedoraproject.org +syncHttpLogs fedocal01.stg.phx2.fedoraproject.org +syncHttpLogs paste01.phx2.fedoraproject.org +syncHttpLogs paste02.phx2.fedoraproject.org +syncHttpLogs paste01.stg.phx2.fedoraproject.org +syncHttpLogs datagrepper01.phx2.fedoraproject.org +syncHttpLogs datagrepper02.phx2.fedoraproject.org +syncHttpLogs datagrepper01.stg.phx2.fedoraproject.org +syncHttpLogs fedoauth01.phx2.fedoraproject.org +syncHttpLogs fedoauth02.phx2.fedoraproject.org +syncHttpLogs fedoauth01.stg.phx2.fedoraproject.org +syncHttpLogs ask01.phx2.fedoraproject.org +syncHttpLogs ask02.phx2.fedoraproject.org +syncHttpLogs ask01.stg.phx2.fedoraproject.org +syncHttpLogs badges-web01.phx2.fedoraproject.org +syncHttpLogs badges-web02.phx2.fedoraproject.org +syncHttpLogs badges-web01.stg.phx2.fedoraproject.org +syncHttpLogs elections01.phx2.fedoraproject.org +syncHttpLogs elections02.phx2.fedoraproject.org +syncHttpLogs elections01.stg.phx2.fedoraproject.org +syncHttpLogs tagger01.phx2.fedoraproject.org +syncHttpLogs tagger02.phx2.fedoraproject.org +syncHttpLogs tagger01.stg.phx2.fedoraproject.org +syncHttpLogs bodhi01.phx2.fedoraproject.org +syncHttpLogs bodhi02.phx2.fedoraproject.org +syncHttpLogs bodhi01.stg.phx2.fedoraproject.org +syncHttpLogs packages03.phx2.fedoraproject.org +syncHttpLogs packages04.phx2.fedoraproject.org +syncHttpLogs packages03.stg.phx2.fedoraproject.org +syncHttpLogs blockerbugs01.phx2.fedoraproject.org +syncHttpLogs blockerbugs02.phx2.fedoraproject.org +syncHttpLogs blockerbugs01.stg.phx2.fedoraproject.org +syncHttpLogs value01.phx2.fedoraproject.org +syncHttpLogs secondary01 +syncHttpLogs hosted03.vpn.fedoraproject.org old +syncHttpLogs hosted04.vpn.fedoraproject.org old +syncHttpLogs people03.vpn.fedoraproject.org old +syncHttpLogs noc01.phx2.fedoraproject.org +syncHttpLogs download01.phx2.fedoraproject.org +syncHttpLogs download02.phx2.fedoraproject.org +syncHttpLogs download03.phx2.fedoraproject.org +syncHttpLogs download04.phx2.fedoraproject.org +syncHttpLogs download05.phx2.fedoraproject.org +syncHttpLogs download-rdu01.vpn.fedoraproject.org +syncHttpLogs download-rdu02.vpn.fedoraproject.org +syncHttpLogs download-rdu03.vpn.fedoraproject.org +syncHttpLogs sundries01.phx2.fedoraproject.org +syncHttpLogs sundries02.phx2.fedoraproject.org +syncHttpLogs sundries01.stg.phx2.fedoraproject.org +## eof diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index e3fc36acaa..a461a0927e 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -229,3 +229,10 @@ tags: - config - base + +- name: install a sync httpd logs cron script only on log01 + copy: src=syncHttpLogs.sh dest=/etc/cron.daily/syncHttpLogs.sh mode=755 + when: inventory_hostname.startswith('log01') + tags: + - config + - base