Dovecot Stats for Logwatch

Plutocrat plutocrat at gmail.com
Thu Jun 3 04:58:18 EEST 2021


Sure, it was meant to be a quick and dirty solution for my particular needs, and I'm sure there are many things that could be done better, neater, tidier. But I just thought I'd stick it up there in case it helped anyone.

For handling both compressed and uncompressed files, I believe you can use 'zcat -f', which might be easier. In my particular case, I have weekly log rotation, so I only needed the two named ones to guarantee 24 hours of logs.

Fair commend about the TEMPFILE. Must have pasted an older version to the one I eventually used on the server. Will correct it.

Aki, I did look at the dovecot stats module, but after spending a few hours without success, I decided to take the path of least resistance and just hack up a script which probably took me an hour. Anyway thanks for your help and patience on that. I'd probably persevere with that approach if I was in corporate mode, and especially if I needed historical / comparative data.

P.

On 02/06/2021 16.41, @lbutlr wrote:
> On 02 Jun 2021, at 02:10, Plutocrat <plutocrat at gmail.com> wrote:
>> Its here if anyone can use it. Any suggestions for improvement welcome. Use at your own risk etc.
>>
>> https://gist.github.com/plutocrat/8a2033923e14670dd13611fc0b51fc0f
> 
> This looks good. My only comment is the script doesn't account for compressed logs.
> 
> LOG1="/var/log/dovecot.log.0.bz2"
> LOG2="/var/log/dovecot.log"
> bzcat $LOG1 | sed "0,/^$STARTTIME/d" > $TEMPFILE
> cat $LOG2 >> $TEMPFILE
> 
> Well, another comment, I think you meant these tow lines to read like this:
> 
> STARTDATE=$(head -n 1 $TEMPFILE | awk '{print $1 " " $2 " " $3 }')
> ENDDATE=$(tail -n 1 $TEMPFILE | awk '{print $1 " " $2 " " $3 }')
> 
> Though I don't think the awk is necessary, the first 15 characters of the first and last lines contain the info you want to display.
> 
> Of course, it would begetter to handle this all transparently, but … meh.
> 


More information about the dovecot mailing list