Supported OS Linux Mac OS

インテグレーションバージョン3.0.0

To find out if this integration is available in your organization, see your Datadog Integrations page or ask your organization administrator.

To initiate an exception request to enable this integration for your organization, email [email protected].

Postfix Graph

概要

このチェックは、すべての Postfix キューのサイズを監視します。

セットアップ

インストール

Postfix チェックは Datadog Agent パッケージに含まれています。Postfix サーバーに追加でインストールする必要はありません。

構成

このチェックは、find コマンドを使用するように構成できます。このコマンドを使用するには、incomingactive、および deferred メールキュー内のメッセージカウントを取得するために、dd-agent への sudo アクセスを許可する必要があります。

オプションで、組み込みの postqueue -p コマンドを使用して activehold、および deferred メールキュー内のメッセージカウントを取得するように Agent を構成できます。postqueuesudo は必要なく、設定されたグループ ID の権限で実行されます。

警告: postqueue を使用してメールキューを監視する場合、incoming キューのメッセージカウントは報告されません。

メトリクスの収集

sudo を使用する場合
  1. Agent のコンフィギュレーションディレクトリのルートにある conf.d/ フォルダーの postfix.d/conf.yaml ファイルを編集します。使用可能なすべてのコンフィギュレーションオプションの詳細については、postfix.d/conf.yaml のサンプル を参照してください。

    init_config:
      ## @param postfix_user - string - required
      ## The user running dd-agent must have passwordless sudo access for the find
      ## command to run the postfix check.  Here's an example:
      ## example /etc/sudoers entry:
      ##   dd-agent ALL=(postfix) NOPASSWD:/usr/bin/find /var/spool/postfix/incoming -type f
      ##
      ## Redhat/CentOS/Amazon Linux flavours need to add:
      ##          Defaults:dd-agent !requiretty
      #
      postfix_user: postfix
    
    instances:
      ## @param directory - string - optional - default: /var/spool/postfix
      ## Path to the postfix directory. The directory option is required if `postqueue: false` is set. For more 
      ## information see https://docs.datadoghq.com/integrations/postfix/#using-sudo.
      #
      - directory: /var/spool/postfix
    
        ## @param queues - list of string - required
        ## List of queues to monitor.
        #
        queues:
          - incoming
          - active
          - deferred
    
  2. queues 内の各メールキューに対して、Agent は、そのディレクトリ上で find をフォークします。これは、Postfix ユーザーの権限で sudo を使用して実行されます。そのため、Agent のユーザーである dd-agent/etc/sudoers に以下の行を追加する必要があります。Postfix は postfix として実行されているとします。

    dd-agent ALL=(postfix) NOPASSWD:/usr/bin/find /var/spool/postfix/incoming -type f
    dd-agent ALL=(postfix) NOPASSWD:/usr/bin/find /var/spool/postfix/active -type f
    dd-agent ALL=(postfix) NOPASSWD:/usr/bin/find /var/spool/postfix/deferred -type f
    
  3. Agent を再起動します

postqueue を使用する場合
  1. Agent のコンフィギュレーションディレクトリのルートにある conf.d/ フォルダーの postfix.d/conf.yaml ファイルを編集します。

    init_config:
      ## @param postqueue - boolean - optional - default: false
      ## Set `postqueue: true` to gather mail queue counts using `postqueue -p`
      ## without the use of sudo. Postqueue binary is ran with set-group ID privileges,
      ## so that it can connect to Postfix daemon processes.
      ## Only `tags` keys are used from `instances` definition.
      ## Postfix has internal access controls that limit activities on the mail queue.
      ## By default, Postfix allows `anyone` to view the queue. On production systems
      ## where the Postfix installation may be configured with stricter access controls,
      ## you may need to grant the dd-agent user access to view the mail queue.
      ##
      ## postconf -e "authorized_mailq_users = dd-agent"
      ##
      ## http://www.postfix.org/postqueue.1.html
      ##
      ## authorized_mailq_users (static:anyone)
      ## List of users who are authorized to view the queue.
      #
      postqueue: true
    
    instances:
      ## @param config_directory - string - optional
      ## The config_directory option only applies when `postqueue: true`.
      ## The config_directory is the location of the Postfix configuration directory
      ## where main.cf lives.
      #
      - config_directory: /etc/postfix
    
        ## @param queues - list of string - required
        ## List of queues to monitor.
        #
        queues:
          - incoming
          - active
          - deferred
    
  2. instances 内の各 config_directory について、Agent は、Postfix コンフィギュレーションディレクトリに対して postqueue -c をフォークします。Postfix は、メールキューに対するアクティビティを内部アクセス制御によって制限しています。デフォルトでは、Postfix は anyone にキューの表示を許可します。実稼働システムの Postfix インストレーションで、より厳密にアクセス制御が構成されている場合は、dd-agent ユーザーにメールキューの表示アクセスを許可することが必要な場合があります。詳しくは、postqueue Postfix のドキュメントを参照してください。

    postconf -e "authorized_mailq_users = dd-agent"
    

    キューの表示を許可されたユーザーのリスト。

    authorized_mailq_users (static:anyone)
    
  3. Agent を再起動します

ログ収集

Agent バージョン 6.0 以降で利用可能

Postfix は syslog デーモンにログを送信し、そのログがファイルシステムに書き込まれます。命名規則とログファイルの送信先は構成可能です。

/etc/syslog.conf:
    mail.err                                    /dev/console
    mail.debug                                  /var/log/mail.log
  1. Datadog Agent で、ログの収集はデフォルトで無効になっています。以下のように、datadog.yaml ファイルでこれを有効にします。

    logs_enabled: true
    
  2. 次の構成ブロックを postfix.d/conf.yaml ファイルに追加します。それぞれの環境に応じて、path パラメーターと service パラメーターの値を変更してください。使用可能なすべてのコンフィギュレーションオプションの詳細については、postfix.d/conf.yaml のサンプル を参照してください。

    logs:
      - type: file
        path: /var/log/mail.log
        source: postfix
        service: myapp
    
  3. Agent を再起動します

検証

Agent の status サブコマンドを実行し、Checks セクションで postfix を探します。

収集データ

メトリクス

postfix.queue.size
(gauge)
The number of messages in a given mail queue, tagged by queue name (e.g. ‘queue:incoming’) and directory (e.g. ‘instance:/var/spool/postfix/incoming’).
Shown as email

イベント

Postfix チェックには、イベントは含まれません。

サービスチェック

Postfix チェックには、サービスのチェック機能は含まれません。

トラブルシューティング

ご不明な点は、Datadog のサポートチームまでお問い合わせください。

その他の参考資料

お役に立つドキュメント、リンクや記事: