[rrd-users] Graphing a rotating logfile

Simon Hobson linux at thehobsons.co.uk
Mon Mar 21 08:30:17 CET 2011

Steve Shipway wrote:
>  > I'm currently thinking about graphing the php error log to see how much
>>  errors/warnings/notices are generated over time.
>>  Can anyone tell me if I can use a simple: grep -c "Error" php.log to get
>>  the stats or do I have to script something that deals with the daily
>>  logfile rotation? Does the overflow function in COUNTER help with the
>>  rotation?
>I assume this file grows during the day, and ten is set to empty at 
>some set time (eg, midnight).
>If you set the type to be a COUNTER, and input the total number of 
>'Error' lines, then youll get a constantly rising number during the 
>day, so you can measure a rate from it.
>When the file resets, the rate will either go negative (if the count 
>wasn't so high) or it could possibly trigger the counter-rollover 
>checks and give a very high rate.
>You can set the min/max values to 0 and something reasonable, so 
>that the rollover merely results in a single 'unknown' being logged 
>(the massive or negative value being dropped).

Or, if you make the script a little more intelligent, you can detect 
the logfile rotation (trigger the script from the logfile rotation 
script ?) and it can then do :
- update with size of last file
- update with unknown
- update with zero

The first step is optional (if your last update would have been very 
recent), but the 2nd and 3rd steps will effectively reset to the 
counter to zero without all the wrap around detection stuff kicking 
in and potentially putting in some huge number.

Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.

More information about the rrd-users mailing list