func (m *MySQL) Description() string {
	return "Read metrics from a MySQL server"
}
Description - XXX
package mysql
import (
	"database/sql"
	"encoding/json"
	"net/url"
	"strconv"
	"strings"
	"github.com/mitchellh/mapstructure"
	_ "github.com/go-sql-driver/mysql"
	log "github.com/Sirupsen/logrus"
	"github.com/amonapp/amonagent/plugins"
)
type Config struct {
	Host string
	DB   string
}
func (m *MySQL) Start() error {
	return nil
}
func (m *MySQL) Stop() {
}
var sampleConfig = `
#   Available config options:
#
#    {"host": "username:password@protocol(address)/dbname"}
#
# Config location: /etc/opt/amonagent/plugins-enabled/mysql.conf
`
func (m *MySQL) SampleConfig() string {
	return sampleConfig
}
func (m *MySQL) SetConfigDefaults() error {
	configFile, err := plugins.UmarshalPluginConfig("mysql")
	if err != nil {
		log.WithFields(log.Fields{"plugin": "mysql", "error": err.Error()}).Error("Can't read config file")
	}
	var config Config
	decodeError := mapstructure.Decode(configFile, &config)
	if decodeError != nil {
		log.WithFields(log.Fields{"plugin": "mysql", "error": decodeError.Error()}).Error("Can't decode config file")
	}
	u, _ := url.Parse(config.Host)
	config.DB = strings.Trim(u.Path, "/")
	m.Config = config
	return nil
}
type MySQL struct {
	Config Config
}
var Counters = map[string]string{
	"Connections":              "net.connections",
	"Innodb_data_reads":        "innodb.data_reads",
	"Innodb_data_writes":       "innodb.data_writes",
	"Innodb_os_log_fsyncs":     "innodb.os_log_fsyncs",
	"Innodb_row_lock_waits":    "innodb.row_lock_waits",
	"Innodb_row_lock_time":     "innodb.row_lock_time",
	"Innodb_mutex_spin_waits":  "innodb.mutex_spin_waits",
	"Innodb_mutex_spin_rounds": "innodb.mutex_spin_rounds",
	"Innodb_mutex_os_waits":    "innodb.mutex_os_waits",
	"Slow_queries":             "performance.slow_queries",
	"Questions":                "performance.questions",
	"Queries":                  "performance.queries",
	"Com_select":               "performance.com_select",
	"Com_insert":               "performance.com_insert",
	"Com_update":               "performance.com_update",
	"Com_delete":               "performance.com_delete",
	"Com_insert_select":        "performance.com_insert_select",
	"Com_update_multi":         "performance.com_update_multi",
	"Com_delete_multi":         "performance.com_delete_multi",
	"Com_replace_select":       "performance.com_replace_select",
	"Qcache_hits":              "performance.qcache_hits",
	"Created_tmp_tables":       "performance.created_tmp_tables",
	"Created_tmp_disk_tables":  "performance.created_tmp_disk_tables",
	"Created_tmp_files":        "performance.created_tmp_files",
}
var Gauges = map[string]string{
	"Max_used_connections":     "net.max_connections",
	"Open_tables":              "performance.open_tables",
	"Open_files":               "performance.open_files",
	"Table_locks_waited":       "performance.table_locks_waited",
	"Threads_connected":        "performance.threads_connected",
	"Innodb_current_row_locks": "innodb.current_row_locks",
}
var SlowQueriesSQL = `SELECT
	mysql.slow_log.query_time,
	mysql.slow_log.rows_sent,
	mysql.slow_log.rows_examined,
	mysql.slow_log.lock_time,
	mysql.slow_log.db,
	mysql.slow_log.sql_text AS query,
	mysql.slow_log.start_time
FROM
	mysql.slow_log
WHERE
	mysql.slow_log.query_time > 1
ORDER BY
	start_time DESC
LIMIT 30
`
var TablesSizeSQL = `
SELECT table_name as 'table',
	 table_schema as 'database',
	 table_rows as rows,
	 CONCAT(table_schema, '.', table_name) as full_name,
	 data_length as size,
	 index_length as indexes,
	(data_length + index_length) as total,
ROUND(index_length / data_length, 2) as index_fraction
FROM   information_schema.TABLES
WHERE table_schema NOT IN ('information_schema', 'performance_schema', 'mysql')
ORDER  BY data_length + index_length DESC;
`
type TableSizeData struct {
	Headers []string      `json:"headers"`
	Data    []interface{} `json:"data"`
}
type SlowQueriesData struct {
	Headers []string      `json:"headers"`
	Data    []interface{} `json:"data"`
}
func (p PerformanceStruct) String() string {
	s, _ := json.Marshal(p)
	return string(s)
}
type PerformanceStruct struct {
	TableSizeData   `json:"tables_size"`
	SlowQueriesData `json:"slow_queries"`
	Gauges          map[string]interface{} `json:"gauges"`
	Counters        map[string]interface{} `json:"counters"`
}