Last active
January 22, 2023 23:04
-
-
Save henri/e10b60c467432f884ef0632ce865a2a2 to your computer and use it in GitHub Desktop.
disk_space_email_alert.bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# requires sendEmail to be installed. | |
SYSTEM_NAME="hostname" | |
FROM_EMAIL="[email protected]" | |
TO_EMAIL="[email protected] [email protected]" | |
SMTP_SERVER_NAME="smtp.com:587" | |
SMTP_USER_NAME="smtp__user_name" | |
SMTP_PASS="smtp_password" | |
# check available disks-pace | |
# macOS version | |
#boot_drive_percent_used=`df -h | head -n 2 | tail -n 1 | awk '{print $5}' | tr -d "%"` | |
boot_drive_percent_used=`df -h | grep "/System/Volumes/Data" | head -n1 | awk '{print $5}' | tr -d "%"` | |
# Send Email if Storage Over 81% | |
if [ ${boot_drive_percent_used} -ge 1 ] ; then | |
/usr/local/sbin/sendEmail -m "Storage Availability Warning ${boot_drive_percent_used}%\n\n" -f ${FROM_EMAIL} -t ${TO_EMAIL} -u "${SYSTEM_NAME} : Storage Warning :${boot_drive_percent_used}%" -s ${SMTP_SERVER_NAME} -xu ${SMTP_USER_NAME} -xp ${SMTP_PASS} 2>&1 > /dev/null | |
fi | |
#echo ${boot_drive_percent_used} | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment