#!/usr/local/bin/python
# -*- coding: UTF-8 -*-
import MySQLdb
import threading
# author:xx
# time: 2014/8/20
BIGCOUNT=0
COUNT=0
def check(ip,port_2):
global BIGCOUNT
global COUNT
BIGCOUNT+=1
try:
conn = MySQLdb.connect(host=ip,user="xxx",port=port_2,passwd='xx',charset='utf8')
cur = conn.cursor()
cur.execute("show variables like '%slave_exec_mode%';")
result=cur.fetchall()
for i in result:
print ip,port_2,i[1]
if i[1] != "SMART":
COUNT+=1
print "IP:"+ ip , "port:"+str(port_2) ,i[1]
cur.close()
conn.close()
except Exception , ex:
pass
def checkmeta():
conn = MySQLdb.connect(host="xxx,user="rdsrnd",passwd="xxx",db="xx",charset='utf8')
cur = conn.cursor()
sql = """
SELECT
AND t1.type = 'x' limit 10 ;
"""
cur.execute(sql)
result=cur.fetchall()
for i in result:
check(i[0],i[1])
print "共掃描mysql實(shí)例:" +str(BIGCOUNT) , "參數(shù)不是force的有:" +str(COUNT)
cur.close()
conn.close()
for i in xrange(1):
m = threading.Thread(target=checkmeta)
# m.setDaemon(True)
m.start();
#if __name__=="__main__":