Scripted log parsing

by chalupavato   Last Updated May 16, 2019 00:02 AM

I have to write a script either in perl or python. Im having trouble parsing a maillog file. These are the given requirements:

Takes a logfile as a command line argument and prints to a file named hourlyInfo which is not a command line argument the number of postfix rejects every minute and the numbers of amavis quarantines every minute.

Example output should contain one line per minute, so you will have 60 lines (because the logfile we supplied only covers an hour) that have the following format.

Mar 1 hh:mm [postfix rejects:27] [amavis quarantines:30]

Mar 1 hh:mm [postfix rejects:17] [amavis quarantines:33]

*Note the maillog file looks like this:

Mar 1 00:02:05 avas postfix/smtpd[2411]: connect from unknown[]

Mar 1 00:02:05 avas postfix/smtpd[2410]: connect from[]

Mar 1 00:02:05 avas postfix/smtpd[2410]: 6D9C461A83:[]

Mar 1 00:02:05 avas postfix/smtpd[2411]: disconnect from unknown[]

Mar 1 00:02:28 avas amavis[2166]: (02166-05) Passed, -> , Message-ID: , Hits: 0.271

Related Questions

Updated September 21, 2015 18:01 PM

Updated June 15, 2017 15:02 PM

Updated July 18, 2015 13:01 PM

Updated May 22, 2018 21:02 PM

Updated May 13, 2015 17:00 PM