真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

監(jiān)控mysql數(shù)據(jù)庫主從狀態(tài)

python版本2.6.6

為企業(yè)提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計、網(wǎng)站優(yōu)化、營銷型網(wǎng)站、競價托管、品牌運營等營銷獲客服務。創(chuàng)新互聯(lián)建站擁有網(wǎng)絡營銷運營團隊,以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗助力企業(yè)精準獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡品牌塑造、網(wǎng)絡營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認可!

#!/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()

聽大神的修改后代碼:

#!/usr/bin/python

import MySQLdb

def check_mysql():
    try:
         conn=MySQLdb.connect(host='172.7.10.8',user='summer',passwd='summer',

        db='cms')

        cur=conn.cursor(MySQLdb.cursors.DictCursor)
        cur.execute('show slave status')
        result=cur.fetchall()
        if result is None:
            raise EnvironmentError('result is None')
        slave_status=result[0]
        io_thread=slave_status.get('Slave_IO_Running')
        sql_thread=slave_status.get('Slave_SQL_Running')
        if io_thread == "Yes" and sql_thread == "Yes":
            print 'it is status ok'
        else:
            print 'io_status is %s \nsql_status is %s' %(io_thread,sql_thread)

    finally:
        cur.close()
        conn.close()

if __name__ == '__main__':
    check_mysql()
~


網(wǎng)頁題目:監(jiān)控mysql數(shù)據(jù)庫主從狀態(tài)
網(wǎng)站鏈接:http://weahome.cn/article/ieshii.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部