Please keep in mind that I am not from a English speaking country and so my grammar / spelling might not be good.
I have to get specific data out of a mail-log making use of AWK in a script (not a one-liner), however, I’m not able to get the data I want by myself (very limited knowledge).
AWK (WHICH DATA)
The goal of the script is to get the following:
- [DATA] the mail fail-percentage per domain,
- [OUTPUT] which has to be stored in a separate file (e.g. log_faildomain.txt)
- [DATA] the mail deferral-percentage per domain,
- [OUTPUT] which has to be stored in a sep. file (e.g. log_defdomain.txt)
Now the structure of the “test” mail-log is where the problem starts. I have posted a bit of the “test” mail-log in the code section. Furthermore, I have added the test mail-log itself to the attachments.
The structure (copy pasted, (c) Uni-ulm.de):
A message line summarizes the delivery results for a message that has left the queue:
m birth done bytes nk nz nd <sender> qp uid
Here birth and done are timestamps, bytes is the number of bytes in the message, nk is the number of successful deliveries, nz is the number of deferred delivery attempts, nd is the number of failed delivery attempts, sender is the message's return path, qp is the message's long-term queue identifier, and uid is the userid of the user that queued the message. Note that matchup converts sender to lowercase. This can lose information, since a few hosts pay attention to the case in the box part of an address.
A delivery line shows the result of a single delivery attempt:
d result birth dstart ddone bytes
<sender> chan.recip qp uid reason
Here birth, bytes, sender, qp, and uid are message information as above; chan is the channel for this delivery; recip is the recipient address for this delivery; dstart and ddone are timestamps; result is the letter k for success, z for deferral, d for failure; and reason is a more detailed explanation of the delivery result.
The following might help (“what I’m going to do with the data..”):
When I have the data I’m going to put into a prototype graph (made in Excel) and then I should be able to read the data out in a statistical format. I hope this helps clearing things up.
I would be so GRATEFUL if someone would help me with this. Thanks in advance!!
d k 1004274611.163303500 1004274611.220392500 1004274611.672914500 2024 <SCHIEDAM@Gilbert-_en_Ellice-eilanden.com> remote.ALMERE@Hongarije.com 22059 250
m 1004274611.163303500 1004274611.855431500 2024 1 0 0 <SCHIEDAM@Gilbert-_en_Ellice-eilanden.com> 22059 250
d d 1004274655.308560500 1004274655.382174500 1004274655.417475500 1873 <SINT_PANCRAS@Groenland.com> local.VLAARDINGEN@Nieuwzeeland.com 22061 81
m 1004274655.308560500 1004274655.548948500 1873 0 1 0 <SINT_PANCRAS@Groenland.com> 22061 81
d z 1004274655.590566500 1004274655.665621500 1004274776.72770500 2431 <SINT_PANCRAS@Groenland.com> remote.SINT_PANCRAS@Groenland.com 22064 86
d k 1004275066.390660500 1004275066.455900500 1004275066.631254500 1951 <MAASSLUIS@Rhodesie.com> local.SCHIPHOL@Frankrijk.com 22126 81
m 1004275066.390660500 1004275066.639430500 1951 1 0 0 <MAASSLUIS@Rhodesie.com> 22126 81
d k 1004275066.574064500 1004275066.631035500 1004275067.151378500 2082 <MAASSLUIS@Rhodesie.com> remote.LUCHTHAVEN_SCHIPHOL@Zwitserland.com 22130 512
m 1004275066.574064500 1004275067.166109500 2082 1 0 0 <MAASSLUIS@Rhodesie.com> 22130 512
d z 1004274655.590566500 1004275056.212493500 1004275116.242880500 2431 <MAASSLUIS@Rhodesie.com> remote.SINT_PANCRAS@Groenland.com 22064 86
d k 1004275796.535919500 1004275796.610806500 1004275796.786087500 3959 <HOEK_VAN_HOLLAND@Canada.com> local.AMSTERDAM_ZUIDOOST@Frankrijk.com 22250 81
m 1004275796.535919500 1004275796.800460500 3959 1 0 0 <HOEK_VAN_HOLLAND@Canada.com> 22250 81