MySQLCollector
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
- Do not use this tool in production before testing it.
- Please, use when do you need.
- The author is NOT responsible for misuse use of this tool.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request