标签:数据库
python版本2.6.6
#!/usr/bin/python
import MySQLdb
def check_mysql():
status = True
try:
conn=MySQLdb.connect(host=‘172.7.10.8‘,user=‘summer‘,passwd=‘summer‘,db=‘cms‘)
cur=conn.cursor()
cur.execute("show slave status;")
result = cur.fetchall()
io_thread=result[0][10]
sql_thread=result[0][11]
#print io_thread,sql_thread
cur.close()
conn.close()
status = True
if io_thread == "Yes" and sql_thread == "Yes":
print ‘2‘
status = True
else:
print ‘0‘
status = False
except Exception,e:
print Exception,":",e
go = check_mysql()
标签:数据库
原文地址:http://yanruohan.blog.51cto.com/9740053/1942758