Part of the source code in dstat_mysql5_conn.py under the/usr/shared/dstat directory
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] self.vars:self.set2[ Thread[0]] = float (thread[1]) self.set2[ threads ] = Float (thread[1]/float (max[1]) 1.0 *)
Print type (max[1]), type (thread[1])
<type ' str ' > <type ' str ' >
Debug, the data retrieved from the database (number) is STR so
self.set2[' Threads ' = float (thread[1]/float (max[1]) 1.0 * 100)--yes Str[thread[1]]/float[float (max[1])
Modify this code to
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'--mysql5-conn [email protected]
[Email protected] ~]#./mysql5io.SH 1 TenMYSQL5-Cothco%Con0.00 0.001.00 0.661.00 0.661.00 0.661.00 0.661.00 0.661.00 0.661.00 0.661.00 0.661.00 0.661.00 0.66