码迷,mamicode.com
首页 > 数据库 > 详细

dstat mysql5-conn

时间:2014-07-22 22:51:36      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   数据   io   cti   

在/usr/shared/dstat目录下dstat_mysql5_conn.py中的部分源代码
c = self.db.cursor()
c.execute("""show global variables like ‘max_connections‘;""")
max = c.fetchone()
c.execute("""show global status like ‘Threads_connected‘;""")
thread = c.fetchone()
if thread[0] in self.vars:
    self.set2[thread[0]] = float(thread[1])
    self.set2[Threads] = float(thread[1] / float(max[1]) 1.0 * 100)

 

print type(max[1]) ,type(thread[1])

<type ‘str‘> <type ‘str‘>  

调试下,从数据库中获取到的数据(数字) 是str  所以

 self.set2[‘Threads‘] = float(thread[1] / float(max[1]) 1.0 * 100) --是str[thread[1]]/float[float(max[1])

修改这段代码为

self.set2[‘Threads‘] = float(float(thread[1]) / float(max[1]) * 100)
 
#!/bin/bash
#file:mysql5conn.sh
export DSTAT_MYSQL_USER=user
export DSTAT_MYSQL_PWD=pwd

dstat --mysql5-conn $@
[root@shylock ~]# ./mysql5io.sh  1 10
mysql5-co
ThCo %Con
0.00 0.00
1.00 0.66
1.00 0.66
1.00 0.66
1.00 0.66
1.00 0.66
1.00 0.66
1.00 0.66
1.00 0.66
1.00 0.66
1.00 0.66

dstat mysql5-conn,布布扣,bubuko.com

dstat mysql5-conn

标签:style   blog   color   数据   io   cti   

原文地址:http://www.cnblogs.com/jachin/p/3855376.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!