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 scanerrlog.py and jaxml.py to the same directory. Then you can call
scanerrlog.py using the following cronjob.
#! /usr/bin/env bash # # Error Report for httpd # # Requires: # - scanerrlog - http://www.librelogiciel.com/software/ScanErrLog/action_Presentation # - jaxml - http://www.librelogiciel.com/software/jaxml/action_Presentation # cat /var/log/httpd/error_log \ /var/www/vhosts/*/log/error_log \ | python /usr/local/bin/scanerrlog.py -f text \ | /bin/mail -s "`hostname` - Apache Error Report" root@localhost exit 0
- Make sure that this cronjob runs before log rotation takes place.
- 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.
- 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.
Copyright © 2010 - Some Rights Reserved