#!/bin/bash

set -x

export EMAIL_FILE=/root/disk-stats-email.txt
export EMAIL_TO=admin@ducoterra.net

printf "Subject: Driveripper Disk Stats\n\nTo: ${EMAIL_TO}\n\n" > ${EMAIL_FILE}

printf "Pool 0\n" >> ${EMAIL_FILE}
btrfs device stats /btrfs/pool0 >> ${EMAIL_FILE}

printf "\nPool 1\n" >> ${EMAIL_FILE}
btrfs device stats /btrfs/pool1 >> ${EMAIL_FILE}

printf "\nBackup 0\n" >> ${EMAIL_FILE}
btrfs device stats /btrfs/backup0 >> ${EMAIL_FILE}

cat ${EMAIL_FILE} | msmtp ${EMAIL_TO}