Last active
August 29, 2015 14:04
-
-
Save malias/da16293d8f3642b1707b to your computer and use it in GitHub Desktop.
Check Tables bigger than 2GB - Attention, only the filesize will be checked. Perhaps a Query will be a better idea and the table can be cleared before the ibd file is to big
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 | |
# Description: Find Tables bigger than 2GB | |
# to clean up | |
# Global variables | |
TmpLog='/tmp/mysql_table.log' | |
# E-Mail recipients (multiple mail addresses separated by whitespace) | |
email='' | |
# InnoDB Table Files | |
Path='/var/lib/mysql/' | |
# Test TmpLog and create | |
test -f $TmpLog && rm $TmpLog && touch $TmpLog | |
# Find Tables bigger than 2GB | |
find $Path -type f -size +2G \( -name "*.ibd" -o -name "*.MYD" \) -exec du -h {} \; | sort -h -r >> $TmpLog | |
# Send notification | |
send_mail(){ | |
# Check tempfile is empty | |
if [ -s $TmpLog ]; then | |
# Use mailadress(es) from variable | |
for mailaddress in $email; do | |
# Send mail with log output | |
mail -s "** Table size check $(hostname) **" $mailaddress < $TmpLog | |
done | |
fi | |
} | |
# Execute mail function | |
send_mail | |
# End with Return Code | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment