• EnglishEspañol日本語한국어Português
  • Log inStart now

Sendmail integration

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

After setting up our Sendmail integration, we give you a dashboard for your Sendmail metrics.

Install the infrastructure agent

To get data into New Relic, install our infrastructure agent.

You can install the infrastructure agent two different ways:

Configure NRI-Flex for Sendmail

Flex comes bundled with the New Relic infrastructure agent. To create a flex configuration file follow these steps:

  1. Create a file named sendmail-flex-config.yml in this path:

    bash
    $
    /etc/newrelic-infra/integrations.d
  2. Update your configuration file sendmail-flex-config.yml using the following snippet.

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 to forward Sendmail logs to New Relic.

On Linux machines, your log file named logging.yml should be present in this path:

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

Add the following script to the logging.yml file:

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 + Add data 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.