LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 07-08-2011, 05:44 AM   #1
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 36
PHP error notifications? Logwatch?


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.
 
Old 07-12-2011, 12:23 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,758

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
What version of logwatch are you using? .. a quick 'man logwatch' internet search says :-

Quote:
--range range
You can specify a date-range to process. This option is currently limited to only Yesterday, Today and All.
<edit>just noticed your version in the output... check your man pages to see what --range says</edit>

Last edited by kbp; 07-12-2011 at 12:25 AM.
 
Old 07-12-2011, 04:21 AM   #3
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
For what its worth, I am running OSSEC on a machine that I am doing PHP development on. It sends me an alert, usually within seconds, when an Apache or PHP error has been encountered. While not exactly what the application was intended for, it might serve your purpose.
 
1 members found this post helpful.
Old 07-12-2011, 11:48 PM   #4
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by kbp View Post
What version of logwatch are you using? .. a quick 'man logwatch' internet search says :-



<edit>just noticed your version in the output... check your man pages to see what --range says</edit>
Forgot to mention that the Date::Manip module is installed and detected so --range supports all those extra options.

Found the cause for the error too. Apparently logwatch doesn't like single quotes and needs double quotes for the range specification for it to detect them correctly. Fixing the quotes and then tweaking the parameters a bit I got it to work almost as needed. Apparently the stock php script doesn't bother to check PHP Parse Errors from the logs so I need to tweak the script a bit for our needs.

OSSEC seems interesting too, got to delve into it when I have the time.
 
  


Reply

Tags
logwatch, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Understand Logwatch Error cmnorton Linux - Server 3 05-24-2011 12:53 AM
I want to disable logwatch on our RHEL servers to stop the logwatch mail svik Linux - Enterprise 10 08-27-2009 02:51 PM
Kernel error on logwatch: I/O error, dev fd0 custangro Linux - General 1 05-21-2009 12:46 PM
Logwatch error help illNino Linux - Software 3 03-17-2009 06:00 PM
LogWatch error: aacraid:ID(0:03:0); Mechanical Positioning Error ...: 1 Time(s) tor_user Linux - Hardware 1 07-26-2006 05:00 PM


All times are GMT -5. The time now is 01:51 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration