LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-06-2016, 06:58 AM   #1
jassonmc
LQ Newbie
 
Registered: Apr 2016
Location: Zurich
Distribution: CentOS7
Posts: 6

Rep: Reputation: Disabled
SMTP Monitoring probes fill up Postfix maillog


Hello there

I have a single server CentOS 7 with Postfix installed.
Just yesterday I adjusted our separate monitoring server to start probing the SMTP port every 30 sec. The probing works as it should and we will now get outage infos in case 3 probes fail in a row.

The problem with this is, that the Postfix maillog now logs every 30 sec the following 3 lines:

Apr 6 13:17:46 mail postfix/smtpd[4981]: connect from unknown[10.12.34.56]
Apr 6 13:17:46 mail postfix/smtpd[4981]: lost connection after EHLO from unknown[10.12.34.56]
Apr 6 13:17:46 mail postfix/smtpd[4981]: disconnect from unknown[10.12.34.56]

This makes reading the logfile fairly difficult and increases its size unnecessarily.

How can I get rid of those entries? Can I somewhere whitelist that specific host so it does not generate any log entries? I would also be happy if there would be an regexp or pcre solution in order to delete those entries on their way to the maillog.

As a last resort, I would also accept a solution which cleans the maillog let's say every hour from those entries, but I really hope there is a better solution...

Any help is greatly appreciated :-)

Cheers
Juri
 
Old 04-07-2016, 08:26 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by jassonmc View Post
I adjusted our separate monitoring server to start probing the SMTP port every 30 sec.
Juri:
Welcome to LQ!
Tell us more about this probing, in detail, if possible.
What does the "monitoring server" consist of, or what does it do?

Quote:
Originally Posted by jassonmc View Post
delete those entries on their way to the maillog.
Sounds very syslog-like. Are you forwarding logs from the smtp host to the "monitoring server", or perhaps just
a simple test using netcat or telnet type utilities (this "probe")?

As a note from an experienced SysAdmin:
Quote:
Originally Posted by jassonmc View Post
How can I get rid of those entries?
Scared of you.
As a Rule, I never touch logs in this manner.

What is this "probe" and what is this "monitoring server"?

Thanks.
 
1 members found this post helpful.
Old 04-07-2016, 09:50 AM   #3
jassonmc
LQ Newbie
 
Registered: Apr 2016
Location: Zurich
Distribution: CentOS7
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi Habitual

Thanks for your assistance, much appreciated :-)

The monitoring server is a separate Windows box which runs the monitoring software The Dude v4 from Mikrotik.
The Dude is probing every 30 sec a separate CentOS 7 server running Postfix. The probe consists of sending an EHLO to the Postfix server and if a reply is received, the connection gets aborted.

The logfile in question is the standard Postfix logfile /var/log/maillog.

Don't get me wrong; I don't try to hide some activities, I simply don't want my logfile spammed with meaningless stuff. It's like reducing the log level a bit, which is common practice when choosen wisely.

My comment about "getting rid of the entries" was just a generic call...
I usualy try to avoid using a hammer in order to tighten a screw ;-)

So, if I can't "train" Postfix to just not log this kind of traffic, I probably have to setup some scrip which will copy the maillog to a different location and by using sed I should be able to trim it to my needs.

Is there at all a log level setting for postfix?

Cheers
Juri

Last edited by jassonmc; 04-07-2016 at 09:51 AM. Reason: Typo
 
Old 04-07-2016, 10:11 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Juri:

I wonder, can you modify this probe directly? Change its parameters?
A
Code:
netcat -z -v server_ip 25
Can't miss and the output is clear.
Connection to server_ip 25 port [tcp/smtp] succeeded!
works great and creates no overhead that I could see on the receiving host.
 
Old 04-07-2016, 11:01 AM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,345

Rep: Reputation: Disabled
Quote:
Originally Posted by jassonmc View Post
Just yesterday I adjusted our separate monitoring server to start probing the SMTP port every 30 sec. The probing works as it should and we will now get outage infos in case 3 probes fail in a row.

The problem with this is, that the Postfix maillog now logs every 30 sec the following 3 lines:

Apr 6 13:17:46 mail postfix/smtpd[4981]: connect from unknown[10.12.34.56]
Apr 6 13:17:46 mail postfix/smtpd[4981]: lost connection after EHLO from unknown[10.12.34.56]
Apr 6 13:17:46 mail postfix/smtpd[4981]: disconnect from unknown[10.12.34.56]

This makes reading the logfile fairly difficult and increases its size unnecessarily.
This is a very common problem, and I'd love to see a solution.

In order to properly monitor a service, you have to connect to it and verify that it's actually responding. A simple TCP connection may not be enough. I've seen plenty of cases where a hung service or a crashed subcomponent would not affect the TCP listener, so a simple TCP port test in Nagios/Icinga/OpenNMS/etc. would not detect the service outage.
Quote:
Originally Posted by jassonmc View Post
How can I get rid of those entries? Can I somewhere whitelist that specific host so it does not generate any log entries?
The logs are sent by Postfix to the syslog service and from there to the log file(s). syslogd can filter on source, facility and severity, but (AFAIK) not on the contents of the entry itself. That leaves Postfix.

I've done a casual search of the Postfix documentation, but couldn't find any setting that would make connections from specific hosts exempt from logging. However, I did find the exact opposite; the debug_peer_list allows you to define one or more hosts as candidates for debug logging, and there's a debug_peer_level setting that controls the log level for those hosts. You may be able to (ab)use this setting by defining the monitoring server as a "debug peer" and set the logging level to 0, if level 0 happens to mean "no logging".

But really, Postfix ought to have a configuration setting that would prevent connections from certain hosts from being logged. Perhaps you could post a feature request to the postfix-devel mailing list? We can't be the only ones that could use such a feature.
Quote:
Originally Posted by jassonmc View Post
As a last resort, I would also accept a solution which cleans the maillog let's say every hour from those entries, but I really hope there is a better solution...
That would be a really ugly hack. And it's not really doable, since the logging daemon keeps the log files open at all times. You could conceivably add extra functionality to the logrotate script/process, but that would only affect archived logs ... but no. Seriously, don't even think about it.
 
1 members found this post helpful.
Old 04-09-2016, 02:14 AM   #6
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,816

Rep: Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211
Every 30 seconds is overdone. Can you change the monitoring interval to 5 minutes?
And perhaps you can configure a short retry interval, say 1 minute?

Last edited by MadeInGermany; 04-09-2016 at 02:20 AM.
 
Old 04-15-2016, 06:03 AM   #7
jassonmc
LQ Newbie
 
Registered: Apr 2016
Location: Zurich
Distribution: CentOS7
Posts: 6

Original Poster
Rep: Reputation: Disabled
Sorry for not answering earlier, been quite busy the past few days.

@Habitual
As Ser Olmy pointed out, a simple TCP connect is not enough for us, we really want Postfix to respond to our probes

@Ser Olmy
Thanks for getting into this. I tried you interesting idea of setting a debug_peer_level of 0, unfortunately without luck:
After a postfix reload I get: postfix: fatal: invalid debug_peer_level parameter value 0 < 1
And yes, I figured that cleaning the live log with any sort of hack would not be such a great idea. Apart from being a dirty hack, I would also have to stop postfix before I could even touch the log, which I learned later, and that's definitely a show stoper. Well, I was frustrated and thought, that the hammer tactics might be a suitable solution of a last resort in this special case ;-)

@MadeInGermany
We could argue what is the "right" timing to probe a service, but that doesn't solve the issue, it just reduces the amount of log entries.
Since we also want to catch short outages, we rather leave it at 30 sec with 30 sec retry.
But thanks for adding your view.


What next?
----------
I'll have a look at the syslogd options. Maybe there is something I can use in order to strip the lines in question or maybe pipe the output somewhere else, strip the crap and re-inject it to syslogd and have it then delivered to the postfix maillog. But then again, that's again some sort of hack, which is probably pure overkill just to get rid a few log entries...

If that doesn't help, I'll probably go with a solution similar to the one outlined here: http://stackoverflow.com/questions/1...-write-maillog

I won't touch the live logs, promised ;-)
Rather setting up some cron job to copy the live logs to a working directory every now and then and then have the above linked solution applied in order to strip the logs from the bloat.

If anyone has a better solution, I'm all ears.

Thanks all for you assistance so far, much appreciated.

Cheers
Juri
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Postfix Very Slow w/ Odd Maillog Entries Bushytea Linux - Server 5 08-04-2012 06:08 AM
Redhat Network Satellite and monitoring with probes givmeasec Red Hat 10 03-27-2012 08:49 AM
Postfix Maillog relay issue mosharaf_linux Linux - Server 4 07-28-2011 01:46 AM
Postfix SMTP Monitoring 10speed705 Linux - Server 4 06-19-2009 10:23 AM
postfix maillog help.. hct224 Linux - Newbie 3 11-28-2003 03:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration