Created
April 6, 2011 04:37
-
-
Save mix3/905142 to your computer and use it in GitHub Desktop.
MySQLのSlaveの遅延をチェック 遅延発生で赤色に
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/sh | |
color() { | |
printf '\033[%sm%s\033[m\n' "$@" | |
} | |
while true | |
do | |
DATE=`date | sed -e 's/\r\n/\n/g' | sed -e 's/\n//g'` | |
SBM=`echo "show slave status\G" | mysql -u root | grep Seconds | sed -e 's/ Seconds_Behind_Master: //g'` | |
if [ $SBM -gt 0 ]; then | |
color '31;1' "[$DATE] $SBM" | |
else | |
echo [$DATE] $SBM | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment