From 993b750c82fdecc854940eb67807b1c8dd937302 Mon Sep 17 00:00:00 2001 From: Stephen Smoogen Date: Wed, 2 Mar 2016 21:23:30 +0000 Subject: [PATCH] start off with an awstats for log01 --- roles/awstats/files/combineHttp.cron | 1 + roles/awstats/files/combineHttpLogs.sh | 28 ++++++++++++++++++++++++++ roles/awstats/tasks/main.yml | 23 +++++++++++++++++++++ roles/base/tasks/main.yml | 2 +- 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/roles/awstats/files/combineHttp.cron b/roles/awstats/files/combineHttp.cron index e69de29bb2..016a796727 100644 --- a/roles/awstats/files/combineHttp.cron +++ b/roles/awstats/files/combineHttp.cron @@ -0,0 +1 @@ +0 06 * * * root /usr/local/bin/combineHttpLogs.sh diff --git a/roles/awstats/files/combineHttpLogs.sh b/roles/awstats/files/combineHttpLogs.sh index e69de29bb2..2d5d1b35be 100644 --- a/roles/awstats/files/combineHttpLogs.sh +++ b/roles/awstats/files/combineHttpLogs.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# +# The object of this script is to combine multiple http logs from the +# proxy servers and put them into an NFS directory where they can be +# analyzed by other software on other systems. +# + +# Because sync-http may not get all logs for 3 days, we only merge +# things after 4 days. +NUMDAYS=4 +YEAR=$(/bin/date -d "-${NUMDAYS} days" +%Y) +MONTH=$(/bin/date -d "-${NUMDAYS} days" +%m) +DAY=$(/bin/date -d "-${NUMDAYS} days" +%d) + +LOGDIR=/var/log/hosts +HTTPLOG=${LOGDIR}/proxy*/${YEAR}/${MONTH}/${DAY}/http/ + +TARGET=/mnt/fedora_stats/combined-http/${YEAR}/${MONTH}/${DAY} + +AWSTATS=/usr/share/awstats/tools/logresolvemerge.pl + +FILES=$( ls -1 ${HTTPLOG}/*access.log.xz | awk '{x=split($0,a,"/"); print a[x]}' | sort -u ) + +for FILE in ${FILES}; do + TEMP=$(echo ${FILE} | sed 's/\.xz$//') + "perl ${AWSTATS} ${HTTPLOG}/${FILE} > ${TARGET}/${TEMP} +done diff --git a/roles/awstats/tasks/main.yml b/roles/awstats/tasks/main.yml index e69de29bb2..bf40be7105 100644 --- a/roles/awstats/tasks/main.yml +++ b/roles/awstats/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: install awstats package + yum: state=present name=epylog + tags: + - packages + - awstats + +- name: awstats proxy merge script (log01) + copy: src=combineHttpLogs.sh dest=/usr/local/bin/ mode=0755 + when: inventory_hostname.startswith('log01') + tags: + - config + - awstats + +- name: awstats daily cron job to merge old logs + copy: src=combineHttp.cron dest=/etc/cron.d/ mode=0644 + when: inventory_hostname.startswith('log01') + tags: + - cron + - awstats + +#- name: set up http configs for awstats on dataserver + diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 469a7c8b1d..ddc751dbbc 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -408,7 +408,7 @@ # # Watchdog stuff # -- name: See if there's a watchdog device +- name: See if theres a watchdog device stat: path=/dev/watchdog when: ansible_virtualization_role == 'guest' register: watchdog_dev