• /
  • EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

Sendmail integration

Our Sendmail integration monitors the performance of your Sendmail mail transfer agent, helping you quickly instrument and monitor your agent.

Docs site

After setting up the integration with New Relic, see your data in dashboards like these, right out of the box.

Complete the following steps to install the integration:

Install the infrastructure agent

To use the Sendmail integration, you need to first install the infrastructure agent on the same host. The infrastructure agent monitors the host itself, while the integration you'll install in the next step extends your monitoring with Sendmail-specific data.

Use NRI-Flex to capture metrics

Flex allows you to capture Apache Zookeeper metrics. It comes bundled with the New Relic infrastructure agent you installed in the previous step.

  1. Create a file named sendmail-flex-config.yml in the /newrelic-infra/integrations.d path.

  2. Update the sendmail-flex-config.yml with the following configuration example.

    Make sure to replace FAILED_MESSAGES_FILE_NAME references with your file name. To find this file name, go to /var/mail/ and check the file that has been created for failed messages.

    ---
    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+(.*.)

Forward your Sendmail logs to New Relic

You can use our log forwarding capability to forward Sendmail logs to New Relic.

Add the following script to /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

Restart the New Relic infrastructure agent

Before you can start reading your data, use the instructions in our infrastructure agent docs to restart your infrastructure agent.

bash
$
sudo systemctl restart newrelic-infra.service

In a couple of minutes, your application will send metrics to one.newrelic.com.

Find your data

You can choose our pre-built dashboard template named Sendmail to monitor your Sendmail application metrics. Follow these steps to use our pre-built dashboard template:

  1. From one.newrelic.com, go to the + Integrations & Agents page.

  2. Click on Dashboards.

  3. In the search bar, type sendmail.

  4. The Sendmail dashboard should appear. Click on it to install it.

    Your Sendmail dashboard is considered a custom dashboard and can be found in the Dashboards UI. For docs on using and editing dashboards, see our dashboard docs.

    Here is a NRQL query to find your latest message's sent status:

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

    Here is a NRQL query to find view the Sendmail service status:

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

What's next?

To learn more about building NRQL queries and generating dashboards, check out these docs:

  • Introduction to the query builder to create basic and advanced queries.
  • Introduction to dashboards to customize your dashboard and carry out different actions.
  • Manage your dashboard to adjust your display mode, or to add more content to your dashboard.
Copyright © 2024 New Relic Inc.

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