def main():
    config = yaml.load(open("/etc/dmkit/dmkit.yaml"))
    cm = get_cluster_manager()
    for cluster,node in sorted(config["farms"].iteritems()):
        for node_name,item in sorted(node["nodes"].iteritems()):
            try:
                role = item["roles"][0]
                name = "%s_%s" %(cluster,role)
                cursor = cm.get(name).get_cursor()
                # sql = ("select variable_name,"
                #        "case when variable_name like %s "
                #        "then concat(variable_value/1024/1024/1024,'G') "
                #        "else variable_value end variable_value "
                #        "from information_schema.GLOBAL_VARIABLES "
                #        "where variable_name in (%s,%s) order by 1 ")
                # cursor.execute(sql,('%BUFFER%SIZE%','innodb_buffer_pool_size','version'))
                print cluster,node_name,role,
                # for var_name,val_value in cursor.fetchall():
                #    print var_name,':',val_value,';',

                sql = ("select sum(POOL_SIZE),sum(FREE_BUFFERS), sum(HIT_RATE)/count(*)/10 "
                       "from information_schema.INNODB_BUFFER_POOL_STATS")
                cursor.execute(sql)
                total_size, free_size, hit_rate = cursor.fetchone()
                print 'Total_Buffe_Size: %sG; Free_Buffer_size: %sG, Hit_Rate: %s' % (
                        round(total_size * page_size/1024**3, 2),
                        round(free_size * page_size/1024**3, 2),
                        round(hit_rate, 2)
                        )

                print
            except Exception,e:
                print e
        print '****************'
        time.sleep(0.1)
Ejemplo n.º 2
0
def main():
    config = yaml.load(open("/etc/dmkit/dmkit.yaml"))
    cm = get_cluster_manager()
    for cluster,node in sorted(config["farms"].iteritems()):
        for node_name,item in sorted(node["nodes"].iteritems()):
            try:
                role = item["roles"][0]
                name = "%s_%s" %(cluster,role)
                cursor = cm.get(name).get_cursor()
                sql = ("select variable_name, variable_value "
                       "from information_schema.GLOBAL_VARIABLES "
                       "where variable_name in (%s) order by 1 "
                       )
                cursor.execute(sql,('version',))
                for var_name,val_value in cursor.fetchall():
                    if role=='b':
                        print cluster,node_name,role,var_name,':',val_value,';'
                    # if val_value.startswith('5.5'):
                        # print cluster,node_name,role,var_name,':',val_value,';'
                        # sql = "stop slave"
                        # cursor.execute(sql)
                        # time.sleep(0.1)

                        # sql = "CHANGE MASTER TO master_use_gtid = slave_pos"
                        # cursor.execute(sql)
                        # time.sleep(0.1)

                        # sql = "start slave"
                        # cursor.execute(sql)
                    # else:
                        # continue
            except Exception,e:
                print e
        time.sleep(0.1)
def main():
    config = yaml.load(open("/etc/dmkit/dmkit.yaml"))
    cm = get_cluster_manager()
    for cluster,node in sorted(config["farms"].iteritems()):
        for node_name,item in sorted(node["nodes"].iteritems()):
            try:
                role = item["roles"][0]
                name = "%s_%s" %(cluster,role)
                cursor = cm.get(name).get_cursor()
                sql = "select count(*) from information_schema.tables where table_name = %s "
                cursor.execute(sql,'metadata_lock_info')
                print cluster,node_name,role,
                for val_value in cursor.fetchall():
                   print val_value
                print
            except Exception,e:
                print e
        print '****************'
        time.sleep(0.1)
Ejemplo n.º 4
0
def main():
    config = yaml.load(open("/etc/dmkit/dmkit.yaml"))
    cm = get_cluster_manager()
    for cluster,node in sorted(config["farms"].iteritems()):
        for node_name,item in sorted(node["nodes"].iteritems()):
            try:
                role = item["roles"][0]
                name = "%s_%s" %(cluster,role)
                cursor = cm.get(name).get_cursor()
                sql = "select variable_name,variable_value from information_schema.GLOBAL_VARIABLES where variable_name in (%s,%s,%s) order by 1 "
                cursor.execute(sql,('extra_port','report_port','port'))
                print cluster,node_name,role,
                for var_name,val_value in cursor.fetchall():
                   print str(var_name) + ' : ' + str(val_value) + ' ;',
                print
            except Exception,e:
                print e
        print '****************'
        time.sleep(0.1)
def main():
    config = yaml.load(open("/etc/dmkit/dmkit.yaml"))
    cm = get_cluster_manager()
    for cluster,node in sorted(config["farms"].iteritems()):
        for node_name,item in sorted(node["nodes"].iteritems()):
            try:
                role = item["roles"][0]
                name = "%s_%s" %(cluster,role)
                print name
                cursor = cm.get(name).get_cursor()
                sql = "grant select on *.* to backup@'127.0.0.1' identified by '6MigwNY0Rf'"
                cursor.execute(sql)
                sql = "flush privileges"
                cursor.execute(sql)
                # sql1 = "select count(*) as  cn from information_schema.metadata_lock_info"
                # cursor.execute(sql1)
                # rs = cursor.fetchone()
                # print name,rs
            except Exception,e:
                print e
        print '****************'
        time.sleep(0.1)
Ejemplo n.º 6
0
def main():
    config = yaml.load(open("/etc/dmkit/dmkit.yaml"))
    cm = get_cluster_manager()
    for cluster,node in sorted(config["farms"].iteritems()):
        for node_name,item in sorted(node["nodes"].iteritems()):
            try:
                role = item["roles"][0]
                name = "%s_%s" %(cluster,role)
                cursor = cm.get(name).get_cursor()
                sql = ("select variable_name,"
                       "case when variable_name like %s "
                       "then concat(variable_value/1024/1024/1024,'G') "
                       "else variable_value end variable_value "
                       "from information_schema.GLOBAL_VARIABLES "
                       "where variable_name in (%s,%s) order by 1 ")
                cursor.execute(sql,('%BUFFER%SIZE%','innodb_buffer_pool_size','version'))
                print cluster,node_name,role,
                for var_name,val_value in cursor.fetchall():
                   print var_name,':',val_value,';',
                print
            except Exception,e:
                print e
        print '****************'
        time.sleep(0.1)