[rrd-users] Re: program to monitor apache access log?

Jean-Edouard BABIN listes at jeb.com.fr
Wed May 1 19:07:57 MEST 2002


Hi,

I have this script that count number of request and number of virus request
ps: the :> in qx empty the logfile, do not remove it or apache will not
recreat it..., you can log in this file code error and bytes and do not
count virus but code 200,404 and total bytes...
ps2: you will lost log collected between the time you have opened the file
and time you flush it, but the script is not too slow ;)

#!/usr/bin/perl

use lib qw( /usr/local/rrdtool-1.0.33/lib/perl ../lib/perl );
use RRDs;

while (1) {
$line=-1;$virus=0;

open(LOG, "/home/httpd/rrdtool/access_log_tmp");

while (<LOG>) {
$line = $line+1;
        if ($_ =~ /default.ida/)
                {
                if ($_ =~ /default.ida\?XXX/) {$virus = $virus +1;}
                if ($_ =~ /default.ida\?NNN/) {$virus = $virus +1;}
        }
        if ($_ =~ /c\+dir/) {$virus = $virus +1;}
        if ($_ =~ /ApacheBench/) {$line = $line -1;}

}

close (LOG);

qx ":> /home/httpd/rrdtool/access_log_tmp";

RRDs::update "/home/httpd/rrdtool/rrd_files/Apache.rrd", "N:$line:$virus";

sleep (120);

}


On 1/05/02 15:33, Aaron Bush (abush at microcenter.com) wrote:

> 
> Hello,
> 
> I would like to monitor my Apache access log 'real time' by totaling
> some stats such as total requests, bytes, response codes (200, 404,
> etc...).  I'm looking for a script that will tail the log file reading
> in data as the server writes it and dump out some numbers every 5
> minutes that can then be input into rrdtool, has this already been done,
> i don't want to reinvent the wheel?
> 
> Thanks,
> -ab

-- 
   Jean-Edouard BABIN
Mail : Jeb at jeb.com.fr
Web  : www.Jeb.com.fr
Icq  : 27305084
Irc  : Jeb @#Mac-fr , @#So .. UnderNet.org


--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list