Skip to content

Instantly share code, notes, and snippets.

@mix3
Created April 6, 2011 04:37
Show Gist options
  • Save mix3/905142 to your computer and use it in GitHub Desktop.
Save mix3/905142 to your computer and use it in GitHub Desktop.
MySQLのSlaveの遅延をチェック 遅延発生で赤色に
#!/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