• English日本語한국어
  • ログイン今すぐ開始

この機械翻訳は参考用に提供されます。

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、こちらのページをご覧ください。

問題を作成する

Sendmailの統合

Sendmail 統合は、Sendmail メール転送エージェントのパフォーマンスを監視し、エージェントを迅速に計測および監視するのに役立ちます。

Sendmail 統合を設定すると、Sendmail メトリクスのダッシュボードが提供されます。

インフラストラクチャエージェントをインストールします

データを New Relic に取り込むには、インフラストラクチャ エージェントをインストールします。

インフラストラクチャ エージェントは、次の 2 つの方法でインストールできます。

Sendmail 用に NRI-Flex を設定する

Flex は New Relic インフラストラクチャ エージェントにバンドルされています。フレックス構成ファイルを作成するには、次の手順に従います。

  1. このパスに sendmail-flex-config.yml という名前のファイルを作成します。

    bash
    $
    /etc/newrelic-infra/integrations.d
  2. 次のスニペットを使用して構成ファイルsendmail-flex-config.ymlを更新します。

「FAILED_MESSAGES_FILE_NAME」参照を実際のファイル名に置き換えてください。このファイル名を見つけるには、 /var/mail/に移動し、作成されたファイルに失敗したメッセージがないか確認してください。

---
integrations:
- name: nri-flex
config:
name: sendmailFlex
apis:
#check if Sendmail service is up.
- event_type: SendmailUp
commands:
- run: echo "value:$(systemctl status sendmail | grep 'Active':' active (running)' | wc -l)"
split_by: ':'
#check if Sendmail service is down.
- event_type: SendmailDown
commands:
- run: echo "value:$(systemctl status sendmail | grep 'Active':' inactive (dead)' | wc -l)"
split_by: ':'
#Read the number of times SMTP service is unreachable.
- event_type: SendmailSMTPserviceUnreachable
commands:
- run: echo "value:$(cat /var/log/mail.log | grep -E 'stat=Service unavailable' | wc -l)"
split_by: ':'
#Read the count of error message - host not found.
- event_type: SendmailHostNotFound
commands:
- run: echo "value:$(cat /var/log/mail.log | grep -c 'host not found')"
split_by: ':'
#Read the count of error logged.
- event_type: SendmailErrorCount
commands:
- run: echo "value:$(cat /var/log/mail.err | wc -l)"
split_by: ':'
#Read the number of messages accepted for delivery.
- event_type: SendmailMessageAcceptedForDelivery
commands:
- run: echo "value:$(cat /var/log/mail.log | grep -c 'Message accepted for delivery')"
split_by: ':'
#Read the number of messages sent & deferred.
- event_type: SendmailMessageStatus
commands:
- run: echo "sent:$(cat /var/log/mail.log | grep 'stat=Sent' | wc -l)"
split_by: ':'
- run: echo "deferred:$(cat /var/log/mail.log | grep 'stat=Deferred' | wc -l)"
split_by: ':'
#Read the number of messages held by user.
#Go to the path "/var/mail/" and check the file that has been created for failed messages and accordingly update "FAILED_MESSAGES_FILE_NAME" in the below command.
- event_type: SendmailHeldMessage
commands:
- run: echo "value:$(cat /var/mail/FAILED_MESSAGES_FILE_NAME | grep -c 'Subject:')"
split_by: ':'
#Read the number of connection timeout.
- event_type: SendmailConnectionTimeOut
commands:
- run: echo "value:$(cat /var/log/mail.log | grep -c 'timeout')"
split_by: ':'
#Read the recipients with message count.
- event_type: SendmailRecipientsbyMessageCount
commands:
- run: cat /var/log/mail.log | grep "to=<.*.>" | awk '{n=split($7,a,"to="); print a[1],a[2]}' | cut -d "<" -f2 |cut -d ">" -f1 | sort | uniq -c | sort -nr
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [msgCount.total, recipients.total]
regex_match: true
split_by: \s+(\d+)\s+(.*.)
- run: cat /var/log/mail.log | grep "to=<.*.>" | grep "$(date +'%b %e')" | awk '{n=split($7,a,"to="); print a[1],a[2]}' | cut -d "<" -f2 |cut -d ">" -f1 | sort | uniq -c | sort -nr
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [msgCount.latest, recipients.latest]
regex_match: true
split_by: \s+(\d+)\s+(.*.)
#Read the recipients host/domain.
- event_type: SendmailRecipientsHostname
commands:
- run: cat /var/log/mail.log | grep "to=<.*.>" | awk '{print $7}' | grep -oE '[^@]+[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}' | sort | uniq -c
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [hostCount.total, hostname.total]
regex_match: true
split_by: \s+(\d+)\s+(.*.)
- run: cat /var/log/mail.log | grep "to=<.*.>" | grep "$(date +'%b %e')" | awk '{print $7}' | grep -oE '[^@]+[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}' | sort | uniq -c
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [hostCount.latest, hostname.latest]
regex_match: true
split_by: \s+(\d+)\s+(.*.)
#Read the senders with message count.
- event_type: SendmailSendersbyMessageCount
commands:
- run: cat /var/log/mail.log | grep "from=<.*@.*>" | awk '{print $7}' | cut -d "<" -f2 |cut -d ">" -f1 | sort | uniq -c
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [msg.total, senders.total]
regex_match: true
split_by: \s+(\d+)\s+(.*.)
- run: cat /var/log/mail.log | grep "from=<.*@.*>" | grep "$(date +'%b %e')" | awk '{print $7}' | cut -d "<" -f2 |cut -d ">" -f1 | sort | uniq -c
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [msg.latest, senders.latest]
regex_match: true
split_by: \s+(\d+)\s+(.*.)
#Read the senders host/domain.
- event_type: SendmailSendersHostname
commands:
- run: cat /var/log/mail.log | grep "from=<.*.>" | awk '{print $7}' | grep -oE '[^@]+[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}' | sort | uniq -c
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [hostCount.total, hostname.total]
regex_match: true
split_by: \s+(\d+)\s+(.*.)
- run: cat /var/log/mail.log | grep "from=<.*.>" | grep "$(date +'%b %e')" | awk '{print $7}' | grep -oE '[^@]+[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}' | sort | uniq -c
split: horizontal
header_split_by: \s+(\d+)\s+(.*.)
set_header: [hostCount.latest, hostname.latest]
regex_match: true
split_by: \s+(\d+)\s+(.*.)

Sendmail ログを New Relic に転送する

ログ転送を 使用して、Sendmail ログを New Relic に転送できます。

Linux マシンでは、 logging.yml という名前のログ ファイルが次のパスに存在する必要があります。

bash
$
/etc/newrelic-infra/logging.d/

次のスクリプトを logging.yml ファイルに追加します。

logs:
- name: mail.log
file: /var/log/mail.log
attributes:
logtype: sendmail_log
- name: mail.err
file: /var/log/mail.err
attributes:
logtype: sendmail_error

New Relic インフラストラクチャ エージェントを再起動します

データの読み取りを開始する前に、 インフラストラクチャ エージェントのドキュメント の手順に従ってインフラストラクチャ エージェントを再起動します。

bash
$
sudo systemctl restart newrelic-infra.service

数分以内に、アプリケーションはメトリクスを one.newrelic.comに送信します。

データを検索する

Sendmail という名前の事前に構築されたダッシュボード テンプレートを選択して、Sendmail アプリケーションのメトリクスを監視できます。事前に構築されたダッシュボード テンプレートを使用するには、次の手順に従います。

  1. one.newrelic.comから、 + Add data [+ データの追加] ページに移動します。
  2. [ダッシュボード]をクリックします。
  3. 検索バーにsendmailと入力します。
  4. Sendmail ダッシュボードが表示されます。それをクリックしてインストールします。

Sendmail ダッシュボードはカスタム ダッシュボードとみなされ、 Dashboards [ダッシュボード] UI に表示されます。ダッシュボードの使用と編集に関するドキュメントについては、 ダッシュボードのドキュメントを参照してください。

最新のメッセージの送信ステータスを確認するための NRQL クエリは次のとおりです。

SELECT latest(sent) as 'Sent', latest(deferred) as ‘Deferred’
FROM SendmailMessageStatus

Sendmail サービスのステータスを検索して表示するための NRQL クエリを次に示します。

SELECT latest(value) as 'Service Up'
FROM SendmailUp
TIMESERIES AUTO

次は何ですか?

NRQL クエリの作成とダッシュボードの生成の詳細については、次のドキュメントをご覧ください。

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.