Date created: Sunday, June 19, 2011 10:32:05 AM. Last modified: Thursday, August 2, 2018 9:03:00 AM

Email Example: File Server Stats

#!/bin/bash

mailSubject="$HOSTNAME Report: `date +%Y-%m-%d--%H-%M-%S`"
mailTo="mailbox@domain.tld"
mailMessage="/tmp/storage_stats"

stats="/tmp/stats_tmp"
df -hT > $stats
cat $stats > $mailMessage
echo -e >> $mailMessage

find /backup/ -maxdepth 1 -type d | xargs du -hs > $stats
cat $stats >> $mailMessage
echo -e >> $mailMessage

who -b > $stats
cat $stats >> $mailMessage
echo -e >> $mailMessage

uptime > $stats
cat $stats >> $mailMessage
echo -e >> $mailMessage

cat $mailMessage | mail -s "$mailSubject" "$mailTo"