Postfix 통합은 메일 서버 성능에 대한 완전한 그림을 구성하는 데 도움이 됩니다. Postfix 통합은 인프라 모니터링 에이전트를 사용하고 이메일 전송 프로세스, 메일 대기열 및 메시지 개요와 같은 가장 중요한 Postfix 지표가 포함된 사전 구축된 대시보드를 제공합니다.
Postfix 통합을 설정한 후 Postfix 메트릭에 대한 대시보드를 제공합니다.
인프라 에이전트 설치
데이터를 New Relic으로 가져오려면 인프라 에이전트를 설치하십시오. 당사의 인프라 에이전트는 데이터를 수집하고 수집하므로 메일 서버의 성능을 추적할 수 있습니다. NRI-Flex 통합을 지원하려면 버전이 1.10.7 이상이어야 합니다.
두 가지 방법으로 인프라 에이전트를 설치할 수 있습니다.
- 가이드 설치 는 시스템을 검사하고 시스템에 가장 적합한 애플리케이션 모니터링 에이전트와 함께 인프라 에이전트를 설치하는 CLI 도구입니다. 가이드 설치 작동 방식에 대해 자세히 알아보려면 가이드 설치 개요 를 확인하세요.
- 인프라 에이전트를 수동으로 설치하려면 Linux, Windows또는 macOS용 수동 설치에 대한 자습서를 따를 수 있습니다.
Postfix 데이터 내보내기
pflogsumm
사용하여 Postfix 측정항목을 내보냅니다. Pflogsumm
은 Postfix 에이전트용 로그 분석기이며 Postfix 활동에 대한 개요를 제공하도록 설계되었으며 관리자에게 잠재적인 문제 지점에 대한 "헤드 업"을 제공하기에 충분한 세부 정보만 제공합니다.
pflogsumm
사용하려면 다음 단계를 따르세요.
Postfix용 NRI-Flex 구성
Flex는 New Relic 인프라 에이전트와 함께 번들로 제공됩니다. 플렉스 구성 파일을 만들려면 다음 단계를 따르세요.
다음 경로에
postfix-flex-config.yml
이라는 파일을 만듭니다.bash$/etc/newrelic-infra/integrations.d다음 구성으로
postfix-flex-config.yml
파일을 업데이트합니다.EVENT_TYPE
:EVENT_TYPE
NRQL을 사용하여 쿼리할 수 있는 New Relic 데이터베이스 테이블로 간주할 수 있습니다.COMMAND
: 터미널에서 메트릭을 인쇄하는 데 사용되는 명령이 포함되어 있습니다.
구성 파일이 업데이트되면 다음과 같이 표시됩니다.
--- integrations: - name: nri-flex config: name: postfixFlex apis: #check if Postfix service is up. - event_type: PostfixUp commands: - run: echo "value:$(systemctl status postfix | grep 'Active':' active' | wc -l)" split_by: ':'
#check if Postfix service is down. - event_type: PostfixDown commands: - 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: PostfixGrandTotals commands: - run: cat /var/log/mail.log | pflogsumm | grep -A 21 'Grand Totals' split: horizontal set_header: [metricValue, message] regex_match: true split_by: \s+(\d+\w*)\s+(.*)
#Read the number of messages delivered & received in bytes. - event_type: PostfixMessageBytes commands: - run: cat /var/log/mail.log | pflogsumm | grep -A 1 'bytes received' split: horizontal set_header: [metricValue, messageBytes] regex_match: true split_by: \s+(\d+\w*)\s+(.*)
#Read the number of messages held by the user. - event_type: PostfixHeldMessage commands: - run: echo "value:$(cat /var/mail/<USER> | grep -c 'Subject:')" split_by: ':'
#Read the count of SASL authentication failure notifications. - event_type: PostfixSASLauthFailed commands: - 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: PostfixBounceNondeliveryNotification commands: - 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: PostfixEmailDeliveryProcess commands: - 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: PostfixMessageInsertedinMailQ commands: - 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: PostfixMessageHandledBySMTP commands: - 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: PostfixMessageRemovedFromMailQ commands: - run: echo "Rvalue:$(cat /var/log/mail.log | grep 'removed'| wc -l)" split_by: ':'
#Read the number of SMTPD connection. - event_type: PostfixSMTPDconnection commands: - run: echo "value:$(cat /var/log/mail.log | grep ' connect from' | wc -l)" split_by: ':'
#Read the number of SMTPD disconnection. - event_type: PostfixSMTPDdisconnection commands: - run: echo "value:$(cat /var/log/mail.log | grep 'disconnect from' | wc -l)" split_by: ':'
#Read the number of SMTP connection. - event_type: PostfixSMTPconnection commands: - run: echo "value:$(cat /var/log/mail.log | grep ' connect to' | wc -l)" split_by: ':'
#Read the number of SMTP disconnection. - event_type: PostfixSMTPdisconnection commands: - run: echo "value:$(cat /var/log/mail.log | grep 'disconnect to' | wc -l)" split_by: ':'
#Read the number of connection timed out. - event_type: PostfixSMTPDtimedOut commands: - run: echo "value:$(cat /var/log/mail.log | grep 'timeout after CONNECT' | wc -l)" split_by: ':'
#Read the number of connection lost. - event_type: PostfixSMTPDconnectionLost commands: - run: echo "value:$(cat /var/log/mail.log | grep 'lost connection' | wc -l)" split_by: ':'
#Read the per-hour traffic report. - event_type: PostfixMessagePerHourReport commands: - run: cat /var/log/mail.log | pflogsumm -d today | grep -i 'Per-Hour Traffic Summary' -A 27 split: horizontal header_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: true split_by: \s+(\d+-\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)
#Read the per-day traffic summary. - event_type: PostfixMessageTrafficPerDay commands: - 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: horizontal header_split_by: \s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(.*) set_header: [date, received, delivered, deferred, bounced, rejected] regex_match: true split_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: PostfixHostSummary commands: - run: cat /var/log/mail.log | pflogsumm | grep -i 'Host/Domain Summary':' Message Delivery' -A 8 | sed -n '2,9p' split: horizontal header_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: true split_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: horizontal header_split_by: \s+(\w+\s+\w+)\s+(\w+)\s+(.*.) set_header: [msgCount, bytesReceived, hostDetail] regex_match: true split_by: \s+(\d+)\s+(\d+\w*)\s+(.*)
#Read the senders & recipients with message count. - event_type: PostfixSenderRecipientMessageCount commands: - 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: horizontal header_split_by: (.*.) set_header: [sender.msgCount, senders] regex_match: true split_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: horizontal header_split_by: (.*.) set_header: [recipient.msgCount, recipients] regex_match: true split_by: \s+(\d+)\s+(.*)
#Read the daemon message details. - event_type: PostfixDaemonMessage commands: - run: cat /var/log/mail.log | pflogsumm | grep -A 10 'Master daemon messages' split: horizontal set_header: [daemon.msgCount, daemonMessage] regex_match: true split_by: \s*(\d+)\s+(\w+.*.)
#Read the message deferral details. - event_type: PostfixDeferralMessage commands: - run: cat /var/log/mail.log | pflogsumm | grep -A 15 'message deferral detail' | sed '/message bounce detail (by relay)/q' split: horizontal header_split_by: (\s+\w+\s+.*) set_header: [deferral.msgCount, deferralMessage] regex_match: true split_by: \s*(\d+)\s+(\w+.*.)
#Read the warning message details. - event_type: PostfixWarningMessage commands: - 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: horizontal header_split_by: \s+(\w+)\s+(.*) set_header: [Warning.msgCount, warningMessage] regex_match: true split_by: \s*(\d+)\s\s\s(.*.)
#Read the error message details. - event_type: PostfixErrorMessage commands: - run: cat /var/log/mail.log | pflogsumm | grep -C 15 'Fatal Errors' -B 1 -A 10 | sed '/Panics/q' split: horizontal header_split_by: \s+(\w+)\s+(.*) set_header: [Fatal.msgCount, fatalMessage] regex_match: true split_by: \s*(\d+)\s\s\s(.*.)
#Read the message bounce details. - event_type: PostfixBounceMessage commands: - run: cat /var/log/mail.log | pflogsumm | grep -A 10 'message bounce detail (by relay)' | sed '/message reject detail/q' split: horizontal header_split_by: \s+(\w+)\s+(.*) set_header: [Bounce.msgCount, bounceMessage] regex_match: true split_by: \s*(\d+)\s\s\s(.*.)
Postfix 로그를 New Relic으로 전달
Log Forwarding을 사용하여 Postfix 로그를 New Relic에 전달할 수 있습니다.
Linux 시스템에서는 logging.yml
라는 로그 파일이 다음 경로에 있어야 합니다.
$/etc/newrelic-infra/logging.d/
로그 파일을 만든 후 logging.yml
파일에 다음 스크립트를 추가합니다.
logs: - name: mail.log file: /var/log/mail.log attributes: logtype: postfix_maillog
New Relic 인프라 에이전트 다시 시작
데이터 읽기를 시작하기 전에 인프라 에이전트 문서 의 지침을 사용하여 인프라 에이전트를 다시 시작하십시오.
$sudo systemctl restart newrelic-infra.service
몇 분 안에 애플리케이션이 메트릭을 one.newrelic.com으로 보냅니다.
애플리케이션 모니터링
Postfix 애플리케이션 측정항목을 모니터링하기 위해 Postfix
라는 사전 빌드된 대시보드 템플릿을 선택할 수 있습니다. 사전 구축된 대시보드 템플릿을 사용하려면 다음 단계를 따르세요.
- one.newrelic.com 으로 이동하여 + Add data[+ 데이터 추가를]클릭합니다.
- Dashboards [대시보드] 탭을 클릭합니다.
- 검색 상자에
Postfix
입력합니다. - 미리 빌드된 대시보드가 표시되면 클릭하여 계정에 설치하십시오.
Postfix 대시보드는 맞춤형 대시보드로 간주되며 Dashboards [대시보드] UI에서 찾을 수 있습니다. 대시보드 사용 및 편집에 대한 문서는 대시보드 문서 를참조하십시오.
다음은 최신 메시지 레코드의 상태를 보기 위한 NRQL 쿼리입니다.
SELECT * FROM PostfixGrandTotals
다음은 시간당 메시지 레코드를 보기 위한 NRQL 쿼리입니다.
SELECT * FROM PostfixMessagePerHourReport
다음은 뭐지?
NRQL 쿼리 작성 및 대시보드 생성에 대해 자세히 알아보려면 다음 문서를 확인하세요.
기본 및 고급 쿼리를 생성 하기 위한 쿼리 빌더 소개
디스플레이 모드를 사용하거나 대시보드에 더 많은 콘텐츠를 추가할 수 있습니다.