Loading...
 
Skip to main content

Email alerts of hard errors

Another option is GlitchTip



This is to send out an email alert when php hits an out of memory error, copied from an email from ohertel:


/usr/bin/sec I use:

sec - simple event correlator

Command to run in a console
Copy to clipboard
/usr/bin/perl -w /usr/bin/sec -conf=/etc/sec.conf -input=/var/log/php5.log -pid=/var/run/sec.pid -detach -syslog=daemon


Note
In some Debian based systems, the error log might not be at /var/log/php5.log but at /var/log/apache2/error.log


sec.conf looks like this:

Replace email@domain.com with your own email
Copy to clipboard
type=single continue=takenext ptype=regexp pattern=exhausted desc=scan for tw.o memory errors action=add php-memory-errors $0 type=calendar continue=takenext time=* * * * * desc=sec cron context=php-memory-errors action=report php-memory-errors /usr/bin/mail -s "alert:php out of memory error" email@domain.com; delete php-memory-errors;


pattern=exhausted: 'exhausted' is the string grepped in the logfile.

Show PHP error messages