simple mysql show table status script
Date: June 20, 2008
all this little script is doing is measuring Data_length
used by dividing it by Max_data_length
so it can give us a clean number that will be usable for monitoring.
this is still a very dirty script so there will be updates:
#!/bin/bash
FILE_OUT=/tmp/data_out.txt
DB_NAME=eyf
DB_USERNAME=user
DB_PASSWORD=password
function warn_db_info {
awk '{print $1, $7, $8}'| awk '!/NULL/ && !/Name/ {printf "%-25s %7.7f\n", $1, $2/$3}' | awk '{if (NF == 2 && $2 >= .7500000 && $2 <= .9499999) printf "%-25s %7.7f\n", $1, $2}'
}
function crit_db_info {
awk '{print $1, $7, $8}'| awk '!/NULL/ && !/Name/ {printf "%-25s %7.7f\n", $1, $2/$3}' | awk '{if (NF == 2 && $2 >= .9500000) printf "%-25s %7.7f\n", $1, $2}'
}
printf "stats for ${DB_NAME}\n" >> ${FILE_OUT}
printf "more than .7500000 but less than .9499999\n" >>${FILE_OUT}
echo "show table status" | mysql -u${DB_USERNAME} db_${DB_NAME}_alumn -p${DB_PASSWORD} | warn_db_info >>${FILE_OUT}
printf "\n" >>${FILE_OUT}
printf "more than .9500000 up to 1.0000000\n" >>${FILE_OUT}
echo "show table status" | mysql -u${DB_USERNAME} db_${DB_NAME}_alumn -p${DB_PASSWORD} | crit_db_info >>${FILE_OUT}
printf "\n" >>${FILE_OUT}
Leave a Reply