[hobbit] MySQL Replicaiton Script
Domnick Eger
deger at cobercafe.net
Wed May 26 19:56:03 CEST 2010
Much apperciated :)
From: Nicolas [mailto:nico at crysto.org]
Sent: Wednesday, May 26, 2010 10:43 AM
To: hobbit at hswn.dk
Subject: Re: [hobbit] MySQL Replicaiton Script
Hi,
We use this one:
------------
#!/bin/bash
############################################################################################
test -e /usr/local/mysql/bin/mysql && PROG=/usr/local/mysql/bin/mysql
test -e /usr/bin/mysql && PROG=/usr/bin/mysql
MAXDRIFT=5
############################################################################################
MYSQLCOLOR=""
MYSQLLINE=""
HOSTIP=127.0.0.1
IPADDR=127.0.0.1
MACHINE=`uname -n`
MAXSEC=60
MYSQLUSER=root
MYSQLPORT=3306
LINE=`echo "show slave status \G" | ${PROG} -h ${HOSTIP} -u ${MYSQLUSER} -P ${MYSQLPORT} 2>&1`
MASTERPOS=`echo $LINE | grep Read_Master_Log_Pos | awk -F 'Read_Master_Log_Pos: ' '{print $2}' | awk '{print $1}'`
SLAVEPOS=`echo $LINE | grep -i Exec_Master_Log_Pos | awk -F 'Exec_Master_Log_Pos: ' '{print $2}' | awk '{print $1}'`
SLAVEUP=`echo $LINE | grep Running | wc -l`
SLAVE_SECOND_BEHIND_MASTER=`echo $LINE | grep 'Seconds_Behind_Master:' | awk -F 'Seconds_Behind_Master: ' '{print $2}' | awk '{print $1}'`
test $SLAVEUP -eq "1" && DRIFT=$((${MASTERPOS} - ${SLAVEPOS}))
echo "${LINE}" | ${GREP} "Running: No" >/dev/null
if test "$?" -eq "0"
then
MYSQLCOLOR="red"
MYSQLLINE="`${DATE}` MYSQL Slave in error
${LINE}"
elif test ${SLAVEUP} -ne "1"
then
MYSQLCOLOR="green"
MYSQLLINE="`${DATE}` MYSQL Slave is Stopped
${LINE}"
elif test ${SLAVE_SECOND_BEHIND_MASTER} -ge ${MAXSEC}
then
MYSQLCOLOR="yellow"
MYSQLLINE="`${DATE}` MYSQL Slave is ${DRIFT} statements behind!
${LINE}"
else
MYSQLCOLOR="green"
MYSQLLINE="`${DATE}` MYSQL Slave is ${DRIFT} statements behind!
${LINE}"
fi
#echo "${BB} ${BBDISP} status ${MACHINE}.mysqlslave ${MYSQLCOLOR} ${MYSQLLINE}"
${BB} ${BBDISP} "status ${MACHINE}.mysqlslave ${MYSQLCOLOR} ${MYSQLLINE}"
-----------------
To make it working, you need to create the file : ~hobbit/.my.cnf
[mysql]
password=XXXXXXXX
[mysqlclient]
password= XXXXXXXX
[mysqladmin]
password= XXXXXXXX
[mysqlshow]
password= XXXXXXXX
[mysqldump]
password= XXXXXXXX
chown hobbit: ~hobbit/.my.cnf
chmod 600 ~hobbit/.my.cnf
Add the section in clientlaunch.cfg
[mysqlslave]
ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
CMD $HOBBITCLIENTHOME/ext/mysqlslave.sh
LOGFILE $HOBBITCLIENTHOME/logs/mysqlslave.log
INTERVAL 5m
Restart hobbit-client.
Cheers,
Nico
On 26/05/10 19:12, "Domnick Eger" <deger at cobercafe.net> wrote:
Just wanted to see if anyone had a working copy of the MySQL replication script that they would be willing to share ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20100526/dcf2fd48/attachment.html>
More information about the Xymon
mailing list