scripts/mail-logger.homeserver.sh

29 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
mkdir -p /tmp/mail-logger
mkdir -p /tmp/mail-logger-meta
mkdir -p /tmp/mail-logger-big
cp /var/log/borg-cron.log /tmp/mail-logger-big
cp /var/log/btrfs-raid-status.log /tmp/mail-logger
cp /var/log/btrfs-scrub.log /tmp/mail-logger
#cp /var/log/snowboard-download.log /tmp/mail-logger
cat /tmp/mail-logger/* >> /tmp/mail-logger-meta/combined.log
cat /tmp/mail-logger-big/* >> /tmp/mail-logger-meta/combined.log
echo -e "\
Weekly mail report for $(hostname) $(date +"%Y-%m-%dT%H:%M:%S%z").\n\
A summary of the logs is below.\
If you want to see the complete logs, open the attachment of this E-Mail.\n\n\
==================================================================================================\
=====================\n\
" > /tmp/mail-logger-meta/mail.txt
tail -vn 300 /tmp/mail-logger/* >> /tmp/mail-logger-meta/mail.txt
tail -vn 50 /tmp/mail-logger-big/* >> /tmp/mail-logger-meta/mail.txt
mail-script "logs@cscherr.de" "logs@cscherr.de" "weekly mail report for $(hostname) $(date +"%Y-%m-%d")" /tmp/mail-logger-meta/combined.log < /tmp/mail-logger-meta/mail.txt | sendmail -oi -t
rm -rf /tmp/mail-logger*
rm -rf /tmp/mail-logger-meta