Not strictly a question about programming as such, more of a log handling question.
Anyway. My company has multiple clients, and each of these clients have a set of logs that I'd rather much want to get sent to by e-mail to me.
Now, another prerequisite is that they're hilighted by simple HTML.
All that is very well, I've managed to make a hilighter for the given log types. So, what I do is I use logrotate
's prerotate
stuff to send the logs as an e-mail message. Example:
/var/log/a.log /var/log/b.log { daily missingok copytruncate prerotate /usr/bin/python /home/foo/hilight_logs /var/log/{a,b}.log | /usr/sbin/sendmail -FLog\ mailer -fnoreply@client.com me@mydomain.com endscript }
The problem with this approach is basically that logrotate
sucks: it'll run the command for every log file specified in the specifier, and to my knowledge there's no way to know which of the log files is being handled. (Which wouldn't really help anyway.)
Short of repeating the exact same logrotate
up to 10 times on different machines, the only thing I can do is just to get bogged down with log spam every night. And I grew tired of it today, so I ask.
-
hi,
try to replace
prerotate
withfirstaction
. this way your mail command will only be executed one time for all logs defined in a block.this is the text from the man page:
firstaction/endscript The lines between firstaction and endscript (both of which must appear on lines by themselves) are executed once before all log files that match the wildcarded pattern are rotated, before prerotate script is run and only if at least one log will actually be rotated. These directives may only appear inside a log file definition. If the script exits with error, no further processing is done. See also lastaction.
lericson : This I will definitely try. Thanks a million!From Christian
0 comments:
Post a Comment