Skip to main content

Posts

Showing posts with the label mysql performance

Small python script for monitoring MySQL performance

I have few services which use MySQL as database server. I would like to have information about load in PNG  image  or  in Cacti app. MySQL   has  performance information at 'SHOW STATUS' command. Values  which  are monitored :   threads_running, threads_connected, thread_cached, slow_queries  Of course,  it is really easy to add more variables. Connection to MySQL is accomplished by MySQLdb  module. Typical example of usage is below : import MySQLdb mydb = MySQLdb.connect(host = 'hostname', user = 'username', password = 'secret', database = 'mysatabase' ) mycursor = mydb.cursor() mycursor.execute('SQL command') sqlresult = cur.fetchall() Storing data in rrd file is aviable via rrdtools package. This one is present in debian and Centos OS. example of creating file is below: import rrdtool rrdtool.create("myfile.rrd" , "DS:value1:data...