2020-10-21 16:16:32 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2021-01-16 09:16:05 +00:00
|
|
|
# shellcheck source=../scripts/helper-functions.sh
|
|
|
|
. /usr/local/bin/helper-functions.sh
|
2020-10-21 16:16:32 +00:00
|
|
|
|
2019-12-01 08:19:47 +00:00
|
|
|
set -o errexit
|
|
|
|
set -o pipefail
|
|
|
|
set -o nounset
|
2019-09-15 13:40:05 +00:00
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
HOSTNAME=${1}
|
|
|
|
RECIPIENT=${2}
|
|
|
|
SENDER=${3}
|
2019-09-15 13:40:05 +00:00
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
[[ -x /usr/sbin/pflogsumm ]] || errex "Critical: /usr/sbin/pflogsumm not found"
|
2019-09-15 13:40:05 +00:00
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
# shellcheck disable=SC2046
|
2019-09-15 13:40:05 +00:00
|
|
|
BODY=$(gzip -cdfq $(ls -tr /var/log/mail/mail.log*) | /usr/sbin/pflogsumm --problems_first -d yesterday)
|
|
|
|
|
|
|
|
sendmail -t <<EOF
|
2020-10-21 16:16:32 +00:00
|
|
|
From: ${SENDER}
|
|
|
|
To: ${RECIPIENT}
|
|
|
|
Subject: Postfix summary for ${HOSTNAME} sent $(date '+%Y-%m-%d_%H%M%S')
|
2019-09-15 13:40:05 +00:00
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
${BODY}
|
2019-09-15 13:40:05 +00:00
|
|
|
EOF
|