def db_status():
cursor = connection.cursor()
status = collections.OrderedDict()
query = ['Uptime','Queries','Threads_running','Slow_queries','Flush_commands','Open_tables']
for key in query:
sql = ("SHOW STATUS LIKE '%s'") % key
cursor.execute(sql)
for (Variable_name, Value) in cursor:
status[Variable_name] = int(Value)
try:
status['QPS'] = round(status['Queries']/status['Uptime'],2)
except:
status['QPS'] = 0
return status
评论列表
文章目录