Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import MySQLdb
- _PASS = "***"
- _USER = "***"
- _DB = "***"
- # init mysql servers
- server = ('10.0.2.139','10.0.11.89')
- db = range(len(server))
- cur = range(len(server))
- table = []
- #// init db connections
- for i in range(len(server)):
- db[i] = 0
- cur[i] = 0
- try:
- handler = MySQLdb.connect(host=server[i], # your host, usually localhost
- user=_USER, # your username
- passwd=_PASS, # your password
- db=_DB) # name of the data base
- db[i]= handler
- cur[i] = handler.cursor()
- if i == 0:
- cur[i].execute("SHOW TABLES FROM req")
- for row in cur[i].fetchall() :
- table.extend([row[0]])
- except:
- print "Can't establish connection! " + server[i]
- for y in range(len(table)):
- line = table[y] + "\n"
- line2 = ""
- for x in range(len(server)):
- try:
- cur[x].execute("CHECKSUM TABLE " + table[y])
- for rows in cur[x].fetchall() :
- if x == 0:
- val = rows[1];
- if val != rows[1]:
- errorsign = "(!)"
- else:
- errorsign = ""
- line+= str(rows[1]) + errorsign + "\t"
- except:
- line+= "Cant load Checksum" + "\t"
- try:
- cur[x].execute("SELECT COUNT(*) FROM " + table[y])
- for rows in cur[x].fetchall() :
- if x == 0:
- val2 = rows[0];
- if val2 != rows[0]:
- errorsign2 = "(!)"
- else:
- errorsign2 = ""
- line2+= "" + str(rows[0]) + " " + errorsign2 +" \t"
- except:
- line2+= "Cant load Table count" + "\t"
- print line
- print line2 + "\n"
- sample output:
- req_deals
- 575914388 575914388
- 482 482
- req_debug
- 2165742225 483428047(!)
- 3671034 3671034
- req_distris
- 2371885780 2371885780
- 248 248
- req_distris_block_drop
- 3896513511 3896513511
- 3 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement