Register
It is currently Sat Nov 22, 2014 11:55 am

Monitor Apache Log


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Fri Oct 17, 2008 10:53 am   

Joined: Fri Oct 17, 2008 10:45 am
Posts: 3
Location: Canada
# alogd - Apache Log deamon
#This script monitors the apache log and redirects hits to another file.
#It filters out hits from 127.* localhost.
#!/bin/bash

counter=0

alogd=0

log_dir=/home/user/logs

www_log=/home/user/www/logs

date >> $log_dir/alogd

echo > $log_dir/diff

echo > $log_dir/diff2

sudo cp $www_log/access.log $log_dir

while [ $alogd = 0 ]; do

diff -q $log_dir/access.log $www_log/access.log > $log_dir/diff

if grep -q differ $log_dir/diff

then

tail -n 1 $www_log/access.log > $log_dir/diff2

echo > $log_dir/diff

fi

if grep -q 127 $log_dir/diff2

then

echo > $log_dir/diff2

elif

grep -q GET $log_dir/diff2

then

tail -n 1 $log_dir/diff2 >> $log_dir/alogd

let counter=$counter+1

echo $counter Hits... >> $log_dir/alogd

echo

sudo cp $www_log/access.log $log_dir

echo > $log_dir/diff2

else

echo > /dev/null

fi

sleep 10

done

exit 0


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP