error aggregator script

I mentioned an idea a few days ago, where a script would be used to read error logs and log them to Mantis (or some other bug tracker).

I’ve written the first part. [error_checker-20090509.tar.bz2]

When run, the script checks your HTTP error log and reads the last n lines (set using the config.php or add “?maxlines=n” to the URL).

It then aggregates xdebug errors, which tend to run over a few lines, and then lumps all similar errors together, counting the occurrences.

Finally, the lot is printed to screen as a JSON dump, which can be read by JavaScript (through eval or JSON.decode)or by PHP using json_decode.

The program is protected by password (set in config.php) which can be added to the URL or sent as a POST variable.

Oh – you can also tell it to only send back errors that happened after a set unix_date (get it using time in PHP).

Example call:

My plan is to have one of these scripts installed on every machine that I host, and to call it every now and then and add the results to a Mantis bug tracker, using the MD5 of the error as a subject line along with the number of occurrences (you could say that the higher-numbered errors should be fixed quicker because they happen more often).

Leave a Reply

%d bloggers like this: