MySQLCollector Build Status Gem Version Coverage Status

Ruby GEM to collect MySQL Metrics and send them to InfluxDB. It's a fast and easy implementation.

Requirements

Client

Where it's run MySQLCollector.

  • Ruby 1.9.3
  • MySQL 5.x

Server

  • InfluxDB
  • Grafana

Install

MySQLCollector installation is pretty standard:

$ [sudo] gem install mysqlcollector

Create a user and database on MySQL:

mysql> GRANT REPLICATION CLIENT, PROCESS ON *.*
       TO 'mysqlcollector'@'%' IDENTIFIED BY 'mysqlcollector';
mysql> GRANT SELECT ON performance_schema.* TO 'mysqlcollector'@'%';

Create a user and database on InfluxDB:

> CREATE USER mysqlcollector WITH PASSWORD 'mysqlcollector';
> CREATE DATABASE mysqlcollector;

To generate a JSON template for Grafana:

$ mysqlcollector --template > grafana_mysql.json

For more help as import template, please see the doc of grafana.

Basic Usage

For this case, InfluxDB and Grafana running in your local docker, try:

$ mysqlcollector --mysql-host 192.168.99.100 \
                 --influx-host 192.168.99.100

Daemonize

You can daemonize this tool, and send new metric every 30 seconds:

$ mysqlcollector --mysql-host 192.168.99.100 \
                 --influx-host 192.168.99.100 \
                 --daemonize

Debuging

$ mysqlcollector --mysql-host 192.168.99.100 \
                 --influx-host 192.168.99.100 \
                 --debug

Warning

  1. Do not use this tool in production before testing it.
  2. Please, use when do you need.
  3. The author is NOT responsible for misuse use of this tool.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request