Filter maillog

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filter maillog
# 1  
Old 04-01-2014
Linux Filter maillog


I need to take them all fields SendTo and ip address from a file maillog

First I look at all emails from containing the empty field.
# zcat /var/log/mail/maillog-20140331.server1.gz  | grep "from=<>"  | awk '{print $6}' > 1.txt

Mar 30 23:31:24 servidor1 postfix/smtpd[22991]: 113936F601:[]
Mar 30 23:31:24 servidor1 postfix/cleanup[22951]: 113936F601: message-id=<DUB123-W32635AC923EA56AFE20B66CE600@phx.gbl>
Mar 30 23:31:25 servidor1 postfix/qmgr[28523]: 113936F601: from=<>, size=12445186, nrcpt=1 (queue active)
Mar 30 23:31:45 servidor1 postfix/smtp[22981]: 113936F601: to=<>,[]:25, delay=21, delays=1.4/0/0.16/19, dsn=2.0.0, status=sent (250 ok dirdel)
Mar 30 23:31:45 servidor1 postfix/qmgr[28523]: 113936F601: removed

I now need to make a return to the last file and based on the message ID information shows email recipient and the source IP.

This is easy if one email.

# zcat /var/log/mail/maillog-20140331.server1.gz  | grep 113936F601: | grep "to="


# zcat /var/log/mail/maillog-20140331.servidor1.gz  | grep 113936F601: | grep "client="

With this I would do. But do not do it in one pass for all message ID.

Last edited by Jomeaide; 04-01-2014 at 09:30 AM..
# 2  
Old 04-01-2014

Could you please let us know the input and expected output please for same. Also please use code tags for commands as per forum rules.

R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 04-01-2014
Sorry, my English is not good. I think I put code tags, and ouput result.

I need to get out IDs of all messages stored in the file 1.txt, performing a search in the maillog file.

Not if I explain well. Sorry.

---------- Post updated at 02:56 PM ---------- Previous update was at 02:36 PM ----------

I've more or less well resolved.
  zgrep -wf 1.txt /var/log/mail/maillog-20140331.server1.gz > 2.txt

And then I filter the fields that interest me. Thanks for everything.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

2. Shell Programming and Scripting

Grep out ONLY subject from maillog

I have the following entries in maillog. I need to grep out only the subject part from the following entries. Maillog contain following entries. 2013-11-14 03:30:02 1Vgnd4-001qwZ-36 <= U=user P=local S=9797 id=cd3732bbd0fbda5cb16384bb7d5b465d@localhost.localdomain T="Subject... (3 Replies)
Discussion started by: anil510
3 Replies

3. Solaris

Flood Messages in maillog

Hi All, I am getting large number of messages in below file /www/wls8/logs/HOSTS/tswebd01-zd01/maillog/maillog In past 24 hours, it has been increased by near to 1 GB. Can somebody help in finding, from where these messages are being generated and how to I stop them ? Same kind of messages... (11 Replies)
Discussion started by: solaris_1977
11 Replies

4. Shell Programming and Scripting

How to filter

Hi I have a file containing the below lines 1010001001639 1010001001789 1020001001927 1030001001928 1040001002033 1200001002609 1200001003481 1200001004935 I need to filter lines that starts with 101. It would be of great help if its in awk. (6 Replies)
Discussion started by: Naga06
6 Replies

5. UNIX for Advanced & Expert Users

/var/log/maillog isn't updating. Postfix related

can someone please help me figure how i can get maillog to start updating again? it just all of a sudden stopped. and postfix isn't writing to it anymore. I'm running a Ubuntu box 8.04 thanks (2 Replies)
Discussion started by: SkySmart
2 Replies

6. UNIX for Advanced & Expert Users

maillog errrors

Watching my maillog this morning i have discovered some errors but I cant track down whats causing them. Jun 16 11:04:12 ws096 sendmail: m5GExW7e006613: Milter (spamass-milter): timeout before data read Jun 16 11:04:12 ws096 sendmail: m5GExW7e006613: Milter (spamass-milter): to error state Jun... (3 Replies)
Discussion started by: mcraul
3 Replies

7. Shell Programming and Scripting

File filter

Hi Everyone , have a nice i would need a little help on this i have file which contains blocks such as given below <hgsdp:msisdn=923228719047,loc; HLR SUBSCRIBER DATA SUBSCRIBER IDENTITY MSISDN IMSI STATE AUTHD 923228719047 410072110070614 CONNECTED ... (3 Replies)
Discussion started by: Dastard
3 Replies

8. UNIX for Advanced & Expert Users

maillog extract

Hi all, below are some text extracted from maillog. I have a cronjob running at 1720 daily and it will send mails to me. it was working fine on the 27 Sept.Sep 27 17:20:01 venus sendmail: k8R9K0OR032710: from=user1, size=580, class=0, nrcpts=1, msgid=<>,... (1 Reply)
Discussion started by: new2ss
1 Replies

9. Shell Programming and Scripting

maillog - Error Message

dear expert Im using shell script to send mail from unix server. My script like below: #! /bin/sh -f # Set necessary variables #export PATH #PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/contrib/bin PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/contrib/bin:$PATH; export PATH... (0 Replies)
Discussion started by: unknown2205
0 Replies
Login or Register to Ask a Question