当社の Postfix インテグレーションはメール サーバーのデータを 1 つのビューに統合するため、特定の期間に送信、バウンス、または延期されたメールの数を追跡できます。 当社の Postfix インテグレーションは、インフラストラクチャエージェントを使用して、電子メール配信プロセス、メールキュー、メッセージの概要など、最も重要な Postfix メトリックを含む事前構築されたダッシュボードを提供します。

Postfix 統合を設定すると、Postfix メトリクスのダッシュボードが提供されます。
Postfix統合をセットアップする
Postfix 統合をセットアップするには、次の手順を実行します。
インフラストラクチャエージェントをインストールします
Postfix 統合を使用するには、同じホストにインフラストラクチャ エージェントもインストールする必要があります。 インフラストラクチャエージェントはホスト自体を監視しますが、次のステップでインストールする統合は Postfix 固有のデータを使用して監視を拡張します。
Postfix データのエクスポート
pflogsumm
を使用して Postfix メトリクスをエクスポートします。 Postfix エージェントは、Postfix アクティビティに関するメトリクス データに変換するログ アナライザーとしてpflogsumm
を使用します。 これにより、電子メール管理で発生する可能性のある事象を予測するのに十分な詳細が得られます。
pflogsumm
を使用するには、次の手順に従います。
pflogsumm
をダウンロードして抽出するには、次のコマンドを実行します。bash$wget https://jimsun.linxnet.com/downloads/pflogsumm-1.1.3.tar.gzbash$tar xvf pflogsumm-1.1.3.tar.gzpflogsumm
フォルダに移動します。bash$cd pflogsumm-*.*.*pflogsumm.pl
ファイルをパス/usr/local/bin/pflogsumm
にコピーします。bash$sudo cp pflogsumm.pl /usr/local/bin/pflogsumm次の
pflogsumm
コマンドを実行して、Postfix メトリクスをエクスポートします。bash$cat /var/log/mail.log | pflogsumm$cat /var/log/mail.log | pflogsumm -d today
NRI-Flex を Postfix 用に構成する
アプリケーションに依存しない監視ツールである Flex は、 New Relic Infrastructureエージェントにバンドルされています。 Postfix データ用の flex 設定ファイルを作成するには、次の手順に従います。
postfix-flex-config.yml
という名前のファイルを作成します。bash$touch /etc/newrelic-infra/integrations.d/postfix-flex-config.ymlファイル
postfix-flex-config.yml
を更新します。 以下の設定サンプルを参考にして作業することをお勧めします。---integrations:- name: nri-flexconfig:name: postfixFlexapis:#check if Postfix service is up.- event_type: PostfixUpcommands:- run: echo "value:$(systemctl status postfix | grep 'Active':' active' | wc -l)"split_by: ':'#check if Postfix service is down.- event_type: PostfixDowncommands:- run: echo "value:$(systemctl status postfix | grep 'Active':' active' | wc -l)"split_by: ':'#Read the grand totals messages by using the below script.- event_type: PostfixGrandTotalscommands:- run: cat /var/log/mail.log | pflogsumm | grep -A 21 'Grand Totals'split: horizontalset_header: [metricValue, message]regex_match: truesplit_by: \s+(\d+\w*)\s+(.*)#Read the number of messages delivered & received in bytes.- event_type: PostfixMessageBytescommands:- run: cat /var/log/mail.log | pflogsumm | grep -A 1 'bytes received'split: horizontalset_header: [metricValue, messageBytes]regex_match: truesplit_by: \s+(\d+\w*)\s+(.*)#Read the number of messages held by the user.- event_type: PostfixHeldMessagecommands:- run: echo "value:$(cat /var/mail/<USER> | grep -c 'Subject:')"split_by: ':'#Read the count of SASL authentication failure notifications.- event_type: PostfixSASLauthFailedcommands:- run: echo "value:$(cat /var/log/mail.log | grep 'status=deferred (SASL authentication failed' | wc -l)"split_by: ':'#Read the count of bounced non-delivery notifications.- event_type: PostfixBounceNondeliveryNotificationcommands:- run: echo "value:$(cat /var/log/mail.log | grep 'postfix/bounce' | wc -l)"split_by: ':'#Read the number of messages passed through the email delivery process.- event_type: PostfixEmailDeliveryProcesscommands:- run: echo "PICKUPvalue:$(cat /var/log/mail.log | grep 'pickup' | wc -l)"split_by: ':'- run: echo "CLEANUPvalue:$(cat /var/log/mail.log | grep 'cleanup' | wc -l)"split_by: ':'#Read the number of message inserted in mail queue.- event_type: PostfixMessageInsertedinMailQcommands:- run: echo "Ivalue:$(cat /var/log/mail.log | grep 'queue active'| wc -l)"split_by: ':'#Read the number of message handled by SMTP process.- event_type: PostfixMessageHandledBySMTPcommands:- run: echo "SENTmsg:$(cat /var/log/mail.log | grep 'status=sent' | grep "postfix/smtp" | wc -l)"split_by: ':'- run: echo "BOUNCEDmsg:$(cat /var/log/mail.log | grep 'status=bounced' | grep "postfix/smtp" | wc -l)"split_by: ':'- run: echo "DEFERREDmsg:$(cat /var/log/mail.log | grep 'status=deferred' | grep "postfix/smtp" | wc -l)"split_by: ':'#Read the number of message removed from mail queue.- event_type: PostfixMessageRemovedFromMailQcommands:- run: echo "Rvalue:$(cat /var/log/mail.log | grep 'removed'| wc -l)"split_by: ':'#Read the number of SMTPD connection.- event_type: PostfixSMTPDconnectioncommands:- run: echo "value:$(cat /var/log/mail.log | grep ' connect from' | wc -l)"split_by: ':'#Read the number of SMTPD disconnection.- event_type: PostfixSMTPDdisconnectioncommands:- run: echo "value:$(cat /var/log/mail.log | grep 'disconnect from' | wc -l)"split_by: ':'#Read the number of SMTP connection.- event_type: PostfixSMTPconnectioncommands:- run: echo "value:$(cat /var/log/mail.log | grep ' connect to' | wc -l)"split_by: ':'#Read the number of SMTP disconnection.- event_type: PostfixSMTPdisconnectioncommands:- run: echo "value:$(cat /var/log/mail.log | grep 'disconnect to' | wc -l)"split_by: ':'#Read the number of connection timed out.- event_type: PostfixSMTPDtimedOutcommands:- run: echo "value:$(cat /var/log/mail.log | grep 'timeout after CONNECT' | wc -l)"split_by: ':'#Read the number of connection lost.- event_type: PostfixSMTPDconnectionLostcommands:- run: echo "value:$(cat /var/log/mail.log | grep 'lost connection' | wc -l)"split_by: ':'#Read the per-hour traffic report.- event_type: PostfixMessagePerHourReportcommands:- run: cat /var/log/mail.log | pflogsumm -d today | grep -i 'Per-Hour Traffic Summary' -A 27split: horizontalheader_split_by: \s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(.*)set_header:[time,received.perhour,delivered.perhour,deferred.perhour,bounced.perhour,rejected.perhour,]regex_match: truesplit_by: \s+(\d+-\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)#Read the per-day traffic summary.- event_type: PostfixMessageTrafficPerDaycommands:- run: cat /var/log/mail.log | pflogsumm --zero_fill | grep -C 12 'Per-Day Traffic Summary' -B 0 -A 8 | sed '/Per-Hour Traffic Daily Average/q'split: horizontalheader_split_by: \s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(.*)set_header:[date, received, delivered, deferred, bounced, rejected]regex_match: truesplit_by: \s+(\w+\s+\d+\s+\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)#Read the host/domain summary: message delivery & received.- event_type: PostfixHostSummarycommands:- run: cat /var/log/mail.log | pflogsumm | grep -i 'Host/Domain Summary':' Message Delivery' -A 8 | sed -n '2,9p'split: horizontalheader_split_by: \s+(\w+\s+\w+)\s+(\w+)\s+(\w+)\s+(\w+\s+\w+)\s+(\w+\s+\w+)\s+(.*.)set_header:[sentCount, bytesDelivered, defers, avgDaily, maxDaily, host]regex_match: truesplit_by: \s+(\d+)\s+(\d+\w*)\s+(\d+)\s+(\d+.\d+\s+\w)\s+(\d+.\d+\s+\w)\s+(.*)- run: cat /var/log/mail.log | pflogsumm | grep -A 15 'Host/Domain Summary':' Messages Received' | sed '/Senders by message count/q'split: horizontalheader_split_by: \s+(\w+\s+\w+)\s+(\w+)\s+(.*.)set_header: [msgCount, bytesReceived, hostDetail]regex_match: truesplit_by: \s+(\d+)\s+(\d+\w*)\s+(.*)#Read the senders & recipients with message count.- event_type: PostfixSenderRecipientMessageCountcommands:- run: cat /var/log/mail.log | pflogsumm | grep -C 11 'Senders by message count' -B 1 -A 9 | sed '/Recipients by message count/q'split: horizontalheader_split_by: (.*.)set_header: [sender.msgCount, senders]regex_match: truesplit_by: \s+(\d+)\s+(.*)- run: cat /var/log/mail.log | pflogsumm | grep -C 11 'Recipients by message count' -B 1 -A 9 | sed '/Senders by message size/q'split: horizontalheader_split_by: (.*.)set_header: [recipient.msgCount, recipients]regex_match: truesplit_by: \s+(\d+)\s+(.*)#Read the daemon message details.- event_type: PostfixDaemonMessagecommands:- run: cat /var/log/mail.log | pflogsumm | grep -A 10 'Master daemon messages'split: horizontalset_header: [daemon.msgCount, daemonMessage]regex_match: truesplit_by: \s*(\d+)\s+(\w+.*.)#Read the message deferral details.- event_type: PostfixDeferralMessagecommands:- run: cat /var/log/mail.log | pflogsumm | grep -A 15 'message deferral detail' | sed '/message bounce detail (by relay)/q'split: horizontalheader_split_by: (\s+\w+\s+.*)set_header: [deferral.msgCount, deferralMessage]regex_match: truesplit_by: \s*(\d+)\s+(\w+.*.)#Read the warning message details.- event_type: PostfixWarningMessagecommands:- run: cat /var/log/mail.log | pflogsumm | grep -v 'mail_queue_enter' | grep -C 100 'Warnings' -B 1 -A 10 | sed '/Fatal Errors/q'split: horizontalheader_split_by: \s+(\w+)\s+(.*)set_header: [Warning.msgCount, warningMessage]regex_match: truesplit_by: \s*(\d+)\s\s\s(.*.)#Read the error message details.- event_type: PostfixErrorMessagecommands:- run: cat /var/log/mail.log | pflogsumm | grep -C 15 'Fatal Errors' -B 1 -A 10 | sed '/Panics/q'split: horizontalheader_split_by: \s+(\w+)\s+(.*)set_header: [Fatal.msgCount, fatalMessage]regex_match: truesplit_by: \s*(\d+)\s\s\s(.*.)#Read the message bounce details.- event_type: PostfixBounceMessagecommands:- run: cat /var/log/mail.log | pflogsumm | grep -A 10 'message bounce detail (by relay)' | sed '/message reject detail/q'split: horizontalheader_split_by: \s+(\w+)\s+(.*)set_header: [Bounce.msgCount, bounceMessage]regex_match: truesplit_by: \s*(\d+)\s\s\s(.*.)独自に作成したい場合は、yaml ファイルが上記のパターンに従っていることを確認してください。 必要に応じて次の属性を編集します。
EVENT_TYPE
: NRQL を使用してクエリできる New Relic データベース テーブル。COMMAND
: 端末上でメトリクスを出力するために使用されるコマンド。
Postfix ログを New Relic に転送する
Postfix ログを New Relic に転送するには、次の手順に従います。
インフラストラクチャエージェント ディレクトリに
logging.yml
という名前のファイルを作成します。bash$touch /etc/newrelic-infra/logging.d/logging.yml次のスニペットを
logging.yml
ファイルに追加します。logs:- name: mail.logfile: /var/log/mail.logattributes:logtype: postfix_maillog
インフラストラクチャエージェントを再起動します
インフラストラクチャエージェントのドキュメントの指示に従って、インフラストラクチャエージェントを再起動します。 これはほとんどの人にとって機能する基本的なコマンドです。
$sudo systemctl restart newrelic-infra.service
データを見つけて使用する
事前に構築されたダッシュボード テンプレートを使用して Postfix データを簡単に表示するには、次の手順に従ってください。
one.newrelic.comに移動し、 + Integrations & Agentsをクリックします。
Dashboardsタブをクリックします。
検索ボックスに
Postfix
と入力します。事前構築ダッシュボードが表示されたら、それをクリックしてアカウントにインストールします。
Postfix ダッシュボードはカスタムダッシュボードです。 Dashboards UI からアクセスします。 ダッシュボードの使用と編集に関するドキュメントについては、ダッシュボードのドキュメントを参照してください。
データの検索方法と使用方法の詳細については、 「インテグレーション データを理解する」を参照してください。 Postfix データに対する NRQL クエリの例をいくつか示します。
次は何ですか?
NRQL クエリの作成とダッシュボードの生成の詳細については、次のドキュメントをご覧ください。
- 基本的なクエリと高度なクエリを作成するためのクエリ ビルダーの概要。
- ダッシュボードをカスタマイズしてさまざまなアクションを実行するためのダッシュボードの概要。
- ダッシュボードを管理して、 表示モードを調整したり、ダッシュボードにコンテンツを追加したりできます。