Menu

(Solved) : Given Supplied Logfile Write 5 Perl Python Scripts Named Onepl Py Twopl Py Etc Capable Per Q38103756 . . .

Given the supplied logfile, write 5 perl (or python) scriptsnamed one.pl(py), two.pl(py), etc. which are capable of performingthe following tasks on the supplied logs. You should use regularexpressions for this homework and may find this Perl regularexpression cheat sheet and the Python documentation on regularexpressions helpful for this assignment. one.pl(py) Takes a logfileas a command line argument and prints to a file named hourlyInfowhich is not a command line argument the number of postfix rejectsevery minute and the numbers of amavis quarantines every minute.Example output should contain one line per minute, so you will have60 lines (because the logfile we supplied only covers an hour) thathave the following format. Mar 1 hh:mm [postfix rejects:27] [amavisquarantines:30] Mar 1 hh:mm [postfix rejects:17] [amavisquarantines:33] two.pl(py) Opens a file in the current directorycalled log2 which is not a command line argument (you should make acopy of the log file with this name for testing) and print out thenumber of ips postfix was connected by both known and unknown IPsand list the ip with the most known connections and the one withthe most unknown connections. Example output Total Knownconnection: 99 – [x.x.x.x] accounts for 23 connections TotalUnknown connections 32 – [x.x.x.x] accounts for 21 connectionsthree.pl(py) Takes a logfile as a command line argument and printsout the top 5 From address and the top 5 To addresses Exampleoutput (I am only showing 2 from and 1 to, you will need 5 of each)From bill@linux.org 42 From snoopy@freethedogs.net 32 Tobill@microsoft.com 21 … four.pl(py) Opens a file in the currentdir called log4 which is not a command line argument (you shouldmake a copy of the log file with this name for testing) and printout the number of messages rejected based on dnsbl.sorbs.net, howmany unique ips, how many unique from addresses and how many uniqueto addresses Example output 400 messages rejected 23 unique IP’s 27unique from addresses 12 unique to address five.pl(py) Takes alogfile as a command line argument alters it to cover your tracks.It will remove any line containing any word supplied on the commandline as an argument following the file name The following executionwould remove any line that contained reject or bill@ microsoft.comor dnsbl. ./five.pl logfile reject bill@microsoft.com dnsbl

This is how the logfile looks like:

Mar 1 00:00:02 avas postfix/smtpd[2410]: lost connection afterRCPT from unknown[218.246.34.68]
Mar 1 00:00:02 avas postfix/smtpd[2410]: disconnect fromunknown[218.246.34.68]
Mar 1 00:00:02 avas postfix/smtpd[1822]: connect fromunknown[62.113.122.52]
Mar 1 00:00:03 avas postfix/smtpd[1822]: 4EC6561A83_client=unknown[62.113.122.52]
Mar 1 00:00:03 avas postfix/smtpd[2314]: connect fromhost81-153-11-97.range81-153.btcentralplus.com[81.153.11.97]
Mar 1 00:00:03 avas postfix/smtpd[1822]: 4EC6561A83: reject: RCPTfrom unknown[62.113.122.52]: 450 : Sender address rejected: Domainnot found; from= to= proto=ESMTP helo=
Mar 1 00:00:03 avas postfix/smtpd[2314]: C0E5861AA4_client=host81-153-11-97.range81-153.btcentralplus.com[81.153.11.97]
Mar 1 00:00:04 avas postfix/smtpd[2314]: C0E5861AA4: reject: RCPTfrom host81-153-11-97.range81-153.btcentralplus.com[81.153.11.97]:450 : Sender address rejected: Domain not found; from= to=proto=ESMTP helo=
Mar 1 00:00:05 avas postfix/pickup[1473]: 445C261AA4: uid=0from=
Mar 1 00:00:05 avas postfix/cleanup[2400]: 445C261AA4:message-id=<20040301080005.445C261AA4@avas.example.com>
Mar 1 00:00:05 avas postfix/qmgr[23698]: 445C261AA4: from=,size=704, nrcpt=1 (queue active)
Mar 1 00:00:05 avas postfix/smtpd[2314]: disconnect fromhost81-153-11-97.range81-153.btcentralplus.com[81.153.11.97]
Mar 1 00:00:06 avas postfix/smtpd[2579]: connect fromavas.example.com[127.0.0.1]
Mar 1 00:00:06 avas postfix/smtpd[2579]: 4391461A83_client=avas.example.com[127.0.0.1]
Mar 1 00:00:06 avas postfix/cleanup[1666]: 4391461A83:message-id=<20040301080005.445C261AA4@avas.example.com>
Mar 1 00:00:06 avas postfix/qmgr[23698]: 4391461A83: from=,size=1048, nrcpt=1 (queue active)
Mar 1 00:01:06 avas postfix/smtpd[2579]: disconnect fromavas.example.com[127.0.0.1]
Mar 1 00:01:06 avas amavis[2430]: (02430-01) Passed, -> ,Message-ID: <20040301080005.445C261AA4@avas.example.com>,Hits: 0
Mar 1 00:01:06 avas postfix/smtp[2573]: 445C261AA4: to=,relay=127.0.0.1[127.0.0.1], delay=1, status=sent (250 2.6.0 Ok,id=02430-01, from MTA: 250 Ok: queued as 4391461A83)
Mar 1 00:00:06 avas postfix/smtp[2580]: 4391461A83: to=,relay=10.0.0.251[10.0.0.251], delay=0, status=sent (250 CommandDATA Processed mail data Ok)
Mar 1 00:00:13 avas postfix/smtpd[2411]: warning: 208.37.192.234:address not listed for hostname mail.globrite.com

Expert Answer


Answer to Given Supplied Logfile Write 5 Perl Python Scripts Named Onepl Py Twopl Py Etc Capable Per Q38103756 . . .

OR