PDA

View Full Version : Exclude requests from own IPs in clients' logs


meemu
18th May 2007, 13:16
I noticed after a transferring a site from our old web server to the new ISPConfig one that webalizer almost showed twice as many hits as before. So looked at the logs and realised that this was caused by subrequest - the site is heavily using SSI includes. To not log this and not include it in the traffic stats I made this little change to /root/ispconfig/scripts/shell/logs.php. It's a diff against the latest SVN version but also works for older versions (the one I was actually using was ISPConfig-2.2.11).

Hope someone finds this useful.


43a44
>
75,84d75
<
< /// hack to exclude requests from own IP
< ///
< list($ip) = explode(" ",$normal_log,2);
< //var_dump($ip);
< if(in_array($ip,$go_info["isp"]["server_conf"]["ips"])) {
< continue;
< }
< /// end of hack
<
166c157
< ?>
---
> ?>
\ No newline at end of file

falko
19th May 2007, 14:44
You can tell Apache to not log hits to specific files. Put something like this into your vhost configuration:

SetEnvIf Request_URI "^\/somedir\/somefile.html$" dontlog
where somedir/somefile.html is the file (relative to the vhost's document root) that shouldn't be logged in Apache's access log.

And then you add env=!dontlog at the end of your CustomLog directive, e.g.
CustomLog "|/usr/bin/cronolog --symlink=/var/log/httpd/access.log /var/log/httpd/access.log_%Y_%m_%d" combined env=!dontlog

meemu
19th May 2007, 19:26
The patch is for excluding requests *from* the machine's IP (e.g. subrequests from SSI)