From: Peter P. <ro...@ri...> - 2018-09-29 23:49:28
|
On Sat, Sep 29, 2018 at 02:17:55PM -0400, Gene Heskett wrote: > On Saturday 29 September 2018 13:10:49 Juergen Edner wrote: > > > Hi Gene, > > > > > I was subjected to a phishing attack yesterday and again today, and > > > it would have been a lot easier to correlate the messages if > > > fetchmail was logging the time, preferably the date/time at the end > > > of fetching of fetching each mail. Something it is not now, and > > > never has done. And I just reread the man pages without finding a > > > clue. > > > > > > How do I enable this so a date/time exists in the fetchmail.log? > > > > I'm using the following two commands to log the start and end of > > request cyle: > > > > preconnect "echo 'fetchmail: awakened at '`date +'%a, %d %b %G > > %H:%M:%S (%Z)'`" > > > > postconnect "echo 'fetchmail: sleeping at '`date +'%a, %d %b %G > > %H:%M:%S (%Z)'` for xxx seconds > > > THis would triple the size of the log in terms of line count. What I > would really like to do is convert the single log line: > > fetchmail: reading message ghe...@sh...@pop.shentel.net:1 of 1 > (8044 octets) flushed > > to: > > fetchmail: reading message ghe...@sh...@pop.shentel.net:1 of 1 > (8044 octets) flushed 09/27/18 14;51.28 This could be done if you pipe fetchmail's output through some other program that puts a timestamp on each line; multilog, the log processor from the daemontools package, comes to mind, but in a pinch this might be done with a small dedicated program, maybe something like this: #!/usr/bin/perl use 5.012; use strict; use warnings; use POSIX qw(strftime); while (<>) { print strftime('%Y-%m-%d %H:%M:%S', localtime)." $_"; } ...or even something like: #!/bin/sh while read line; do printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line" done But, yes, I do see your point that fetchmail could also do it by itself, although sometimes chaining a couple of tools is a good approach. G'luck, Peter -- Peter Pentchev roam@{ringlet.net,debian.org,FreeBSD.org} pp...@st... PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 |