-1

I want to monitor apache for recent "500 server error". If found send an email to somebody.

I don't know how to search the apache errors.log file for the latest errors.

Script could be PHP or SH. Whichever fits best.

Any help?

Thanks!

JoaquinLarra
  • 117
  • 4
  • 13

1 Answers1

2

You essentially want to "tail" the error file.
See What is the best way in PHP to read last lines from a file?
You also need to consider that you need to keep track of what errors have already been sent so you don't keep sending the same error. And as @Roboticsexpert mentions... you need a way to throttle the errors. you don't want to generate a gazillion errors if there's an error under heavy server load.

Perhaps a more elegant solution is an error handler that does the notifying? http://php.net/manual/en/function.set-error-handler.php

Community
  • 1
  • 1
Brad Kent
  • 4,982
  • 3
  • 22
  • 26