Script for Apache Error Report

The last incident with the php-cgi errors as a result of a bad PHP script made me re-evaluate the daily reports I receive from the server. I realized that a report about the httpd errors that have occured during the previous day, including all virtualhosts, is more important than I had initially thought. Such a report would have brought the problem to my attention much earlier and could also point me to the right direction while I was trying to figure out what was the cause of it. Fortunately, I found a nice error report generator for this purpose.

The script is called scanerrlog and has some quite nice features. I highly recommend you check it out. In order to run it you will also need an extra Python module, jaxml. Download both packages and extract and to the same directory. Then you can call using the following cronjob.

#! /usr/bin/env bash
# Error Report for httpd
# Requires:
#   - scanerrlog -
#   - jaxml -
cat /var/log/httpd/error_log \
    /var/www/vhosts/*/log/error_log \
    | python /usr/local/bin/ -f text \
    | /bin/mail -s "`hostname` - Apache Error Report" root@localhost
exit 0

Some notes:

  1. Make sure that this cronjob runs before log rotation takes place.
  2. The above shell script concatenates the error_log files from the main web server and all virtualhosts. Edit the paths to reflect your server configuration and virtualhost layout.
  3. Edit the path to

Scanerrlog has some quite nice features that let you further customize the report. Make sure you read the help message.

Script for Apache Error Report by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Permissions beyond the scope of this license may be available at Licensing Information.
Copyright © 2010 - Some Rights Reserved