Postfix

Postfix

This template assesses the performance of the Postfix MTA agent installed on the target server. Perl scripts are used for monitoring the performance of queries.

Prerequisites: SSH and Perl installed on the target server. SNMP installed on the target server and permission to monitor master, qmgr and pickup processes.

Credentials: Root credentials on the target server.

Monitored Components:

Note: You need to set thresholds for counters according to your environment. It is recommended to monitor counters for some period of time to understand potential value ranges and then set the thresholds accordingly. For more information, see http://knowledgebase.solarwinds.com/kb/questions/2415.

Postfix statistic from maillog file

This monitor returns the Postfix mail statistic from the maillog file. The returned values are as follows:

Delivered - This component returns the number of successfully delivered messages. Search for these messages in the maillog file using the following search pattern: "status=sent (delivered to".

Forwarded - This component returns the number of successfully forwarded messages. Search for these messages in the maillog file using the following search pattern: "status=sent (forwarded to".

Rejected - This component returns the number of rejected messages. Search for these messages in the; maillog file using the following search pattern: "reject:".

Received - This component returns the number of received messages. Search for these messages in the maillog file using the following search pattern: "postfix/pickup". (Look in the strings for: "sender=" or "uid=").

Discarded - This component returns the number of discarded messages. Search for these messages in the maillog file using the following search pattern: "discard:".

Deferred - This component returns the number of deferred messages. If a message still has recipients for which delivery failed for some transient reason, and the message has been delivered to all the recipients possible, Postfix places the message into the deferred queue. Search for these messages in the maillog file using the following search pattern: "status=deferred".

Bounced - This component returns the number of bounced messages usually caused by undeliverable mail. Search for these messages in the maillog file using the following search pattern: "status=bounced".

Held - This component returns the number of messages held. The administrator can define smtpd access policies and cleanup header and body checks that cause messages to be automatically diverted from normal processing and placed indefinitely in the hold queue. Messages placed in the hold queue stay there until the administrator intervenes. Search for these messages in the maillog file using the following search pattern: "hold:".

Note: By default, the script retrieves this information from the /var/log/maillog file. If this file has another location on the target server, you should correct the path in the script argument box. By default, this monitor has the Count statistic as difference box checked. It will show the total number of messages in the Message field while the Statistic field will show only new messages since the last polling period.

Messages from maillog file

This monitor returns the Postfix service messages statistic from the maillog file. The returned values are as follows:

Fatal - This component returns the number of fatal service messages. Search for these messages in the maillog file using the following search pattern: " fatal:".

Warning - This component returns the number of warning service messages. Search for these messages in the maillog file using the following search pattern: " warning:".

Panic - This component returns the number of panic service messages. Search for these messages in the maillog file using the following search pattern: " panic:".

Error - This component returns the number of error service messages. Search for these messages in the maillog file using the following search pattern: " error:".

Note: By default, the script retrieves this information from the /var/log/maillog file. If this file has another location on the target server, you should correct the path in the script argument box. By default, this monitor has the Count statistic as difference box checked. It will show the total number of messages in the Message field while the Statistic field will show only new messages since the last polling period.

Mail queue

This monitor shows the length of the mail queue.

IMAP4 User Experience Monitor

This component monitor tests an email round trip from your SMTP mail server to your IMAP4 server and measures the time it takes to complete the trip

Note: By default, this component is disabled. To use this component, you should enable it and properly configure it. More information about this monitor can be found here:

POP3 User Experience Monitor

This component monitor tests an email round trip from your SMTP mail server to your POP3 mail server and measures the time it takes to complete the trip.

Note: By default, this component is disabled. To use this component, you should enable it and properly configure it. More information about this monitor can be found here:

SMTP Monitor

This component monitor tests the ability of an SMTP server to accept incoming connections and respond with the correct code.

Process: master

This monitor returns the CPU and memory usage of the Postfix master process using SNMP. The Master daemon is the supervisor of Postfix, and it oversees all other Postfix daemons. The master waits for incoming jobs to be delegated to subordinate daemons. If there is a lot of work to do, the Master can invoke multiple instances of a daemon.

Process: qmgr

This monitor returns the CPU and memory usage of the Postfix qmgr process using SNMP. The qmgr daemon manages the Postfix queues; it is the heart of the Postfix mail system. It distributes delivery tasks to the local, smtp, lmtp, and pipe daemons. After delegating a job, it submits queue file path-name information, the message sender address, the target host (if the destination is remote), and one or more message-recipient addresses to the daemon it delegated the delivery task to.

Process: pickup

This monitor returns the CPU and memory usage of the Postfix pickup process using SNMP. The pickup daemon picks up messages put into the maildrop queue by the local sendmail user client program. After performing a few sanity checks, pickup passes messages to the cleanup daemon.


Portions of this document were originally created by and are excerpted from the following sources:

Ralf Hildebrant and Patrick Koetter, Linus Journal, “Anatomy of Postfix,” Copyright Copyright 2006-2012. 
All rights reserved. Available at:
http://www.linuxjournal.com/article/9454

  • Here's a bash script to monitor the certificate expiration:

    #!/bin/bash
    #
    date1=$(date -d now --iso-8601)
    date2=$(date --date="$(openssl x509 -in /etc/pki/tls/certs/postfix.pem -enddate -noout | cut -d= -f 2)" --iso-8601)
    start_ts=$(date -d $date1 '+%s')
    end_ts=$(date -d $date2 '+%s')
    echo "Statistic.DaysToCertExp: $(( ( end_ts - start_ts )/(60*60*24) ))"
    exit 0

  • Hey, I just found out some important information about this monitor!

    I don't know if this is every environment, but we are running postfix on a Red Hat server. Every now and then, Orion would report the monitor as "down," specifically because the "pickup" process was not running.

    I did some digging into the verbose logs and found that pickup was basically restarting every 1 hour and 40 minutes, like clockwork. A bit more digging on that led me to this article: https://access.redhat.com/solutions/87313

    TL;DR: The "pickup" process services exactly 100 requests, then restarts. The master process sends an update/status request every minute. This means that after 100 minutes (1 hour 40 minutes), the process will end and restart. In our environment, there's also a 3 second startup delay, meaning that the exact timing of the restart can't be perfectly accounted for.

    All this means that the "pickup" process likely should be changed from sending the monitor into a "down" state, and instead trigger a "not running" state. There may be other alternatives, like running more than 1 pickup process, but that's outside my scope of knowledge.

    Hopes this help someone in the future avoid the confusion I've been dealing with!

  • Anyone else have this issue with monitoring postfix queue?  SMTP monitor works fine and the 3 processes,

  • This is awesome yes, but the mail queue, postfix statistics and mail log file dont work as i think it needs a username and private key combination which i cant get working yet.  Just times out when trying to auth against it. 

  • Awesome template! Only one problem: our security STIGS specify that SSH using root should be disabled and this is causing issues with the template. Any suggestions on how to mitigate this issue? I tried using the Linux Script Monitor for SAM but I am not able to find it, Please advise emoticons_happy.png

    thanks!