Mittwoch, 4. Januar 2012

dont log apache mod_status requests

Wenn M/Monit konfiguriert wurde Apache zu überwachen, setzt es in regelmäßigen Abständen Anfragen ab.

127.0.0.1 - - [04/Jan/2012:12:40:02 +0100] "GET /server-status?auto HTTP/1.1" 200 609 "-" "libwww-perl/5.836"

Diese Anfragen blähen die logfiles extrem auf - was nervig seien kann, wenn man die logs mal manuell durchsehen möchte. Man kann Apache beibringen diese Anfragen nicht zu loggen.

In /etc/apache2/mods-enabled/status.conf setzt man eine Umgebungsvariable, dontlog.

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 ::1
   
SetEnv dontlog
</Location>
Dann sucht man die CustomLog Anweisung in der Apache-Konfig und ändert (zb in "sites-available/default" ) die Zeile so ab, dass nur geloggt wird, wenn dontlog nicht gesetzt ist.

CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog


Nurnoch Apache neustarten und dann werden die Anfragen auf /server-status nicht mehr geloggt.

Links:
SetEnv
mod_status
CustomLog Directive

find in *.gz

zgrep

compressed logfiles

logrotate (<- needed)
rsyslog (optional)

uncomment "#compress" in /etc/logrotate.conf

run to test it: logrotate /etc/logrotate.conf -f

optional define olddir in logrotate.conf
eg: olddir /var/log/old
or define it per file.. its up to you.

check if any files missed and create commands in /etc/logrotate.d/ for them..