Created
January 31, 2012 12:07
-
-
Save aabril/1710181 to your computer and use it in GitHub Desktop.
Monitor and force mysql reload if it reaches 90 threads connections.
This file contains 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 | |
LOGFILE="ping_mysql.log" | |
DBUSER="dummyuser" | |
DBPASS="dummypass" | |
DBHOST="localhost" | |
while : | |
do | |
mysqladmin ping -u $DBUSER -p $DBPASS -h $DBHOST >> $LOGFILE | |
mysqladmin status -u $DBUSER -p $DBPASS -h $DBHOST >> $LOGFILE | |
date >> $LOGFILE | |
if [ $(mysqladmin status -u $DBUSER -p $DBPASS -h localhost | awk 'BEGIN {FS=" "}{print $4}') -gt 90 ] | |
then echo "WARNING! MySQL server has reach 90 threads. Forcing reload." >> $LOGFILE | |
service mysql restart | |
fi | |
echo " " >> $LOGFILE | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment