2022-10-17 08:40:09 +00:00
|
|
|
#!/bin/bash
|
2020-10-21 16:16:32 +00:00
|
|
|
|
2022-02-21 10:56:57 +00:00
|
|
|
# shellcheck source=../scripts/helpers/index.sh
|
|
|
|
source /usr/local/bin/helpers/index.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
|
|
|
|
2022-03-26 08:30:09 +00:00
|
|
|
[[ -x /usr/sbin/pflogsumm ]] || _exit_with_error "'/usr/sbin/pflogsumm' not found or executable"
|
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
|