I need to monitor PHP errors / warnings on few of our servers. The idea is to send email to developers / admins when PHP error/warning occurs on the server. Currently we run very ugly shell script from cron to do this which I want to replace with something better.
I was thinking would logwatch be a good candidate for this. Run logwatch from cron every 5 minutes to check php service logs for the last 5 minutes?
I've tried to get logwatch to check logs for last x minutes but so far without luck. Anyone already done this or should I go some other route with this?
I'm using SLES as my test machine. I've installed the logwatch rpm and configured the PHP settings as shown
here.
Currently I can get php log output when specifying '--range All' but how to tell it to display last few minutes logs?
I've tried lot of range variations but nothing seems to work.
For example
Code:
# loogwatch --print --detail High --archives --service php --range '-60 minutes'
Code:
################### Logwatch 7.3.6 (05/19/07) ####################
Processing Initiated: Fri Jul 8 13:35:24 2011
Date Range Processed: -60 minutes
( 2011-Jul-08 )
Period is day.
Detail Level of Output: 10
Type of Output: unformatted
Logfiles for Host: foobar
##################################################################
--------------------- php-messages Begin ------------------------
Warnings:
1 times:
[... Jul 08 07:16:03 2011] fopen(welcome.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in /home/tmy/public_html/foobar.php on line 3
---------------------- php-messages End -------------------------
###################### Logwatch End #########################
Why does logwatch include just the above entry and not anything after it? The above entry was written some 6 hours ago and there's few other PHP errors which happened less than hour ago which aren't listed.
I also tested adding 'for that minute / for those minutes' to the range command but then it won't output anything at all.