try:
import pymysql as MySQLdb
# https://github.com/PyMySQL/PyMySQL
- stderr.write(NAME + ": using pymysql")
+ sys.stderr.write(NAME + ": using pymysql\n")
except ImportError:
- stderr.write(NAME + ": You need to install PyMySQL module to use mysql.chart.py plugin\n")
+ sys.stderr.write(NAME + ": You need to install MySQLdb or PyMySQL module to use mysql.chart.py plugin\n")
+ raise ImportError
+
+ from base import BaseService
- config = [
- {
- 'name' : 'local',
+ # default configuration (overriden by python.d.plugin)
+ # FIXME change password
+ config = {
+ 'local': {
'user' : 'root',
- 'password' : 'a',
+ 'password' : '',
- 'socket' : '/var/run/mysqld/mysqld.sock'
+ 'socket' : '/var/run/mysqld/mysqld.sock',
+ 'update_every' : 3,
+ 'retries' : 4,
+ 'priority' : 100
}
- ]
+ }
+ # default module values (can be overridden per job in `config`)
update_every = 3
priority = 90000
+ retries = 7
- #query = "SHOW GLOBAL STATUS WHERE value REGEX '^[0-9]'"
+ # query executed on MySQL server
QUERY = "SHOW GLOBAL STATUS"
+
+ # charts order (can be overriden if you want less charts, or different order)
ORDER = ['net',
'queries',
'handlers',
pass
if len(lines) > 0:
print(header + lines + "END")
-
- if len(config) == 0:
- return False
- return True
+
+ return True
-
-#FIXME debug only:
-if __name__ == "__main__":
- my = Service(config['local'],'loc')
- my.check()
- my.create()
- my.update(1)