diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9277911 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM pataquets/collectd-python-pip + +RUN \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get -y install libmysqlclient-dev \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache mysqlclient + +RUN \ + ln -vs /etc/collectd/conf-available/write-csv-stdout.conf \ + /etc/collectd/conf.d/ \ + && \ + nl \ + /etc/collectd/collectd.conf \ + /etc/collectd/conf.d/* diff --git a/README.md b/README.md index df02a08..23f1ad9 100644 --- a/README.md +++ b/README.md @@ -322,5 +322,8 @@ For versions of MySQL with support for it and where enabled, `INFORMATION_SCHEMA response_time_total.14 response_time_count.14 +## Development +A Docker Compose manifest with a stack for testing and development is provided. Just issue ```docker-compose up --build``` to start it. See ```docker-compose.yml``` and ```mysql.conf``` files for configuration details. + ## License MIT (http://www.opensource.org/licenses/mit-license.php) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b3ef6f4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +# Docker Compose development manifest +# This manifest spins up a MariaDB/MySQL server container and builds a +# collectd+python image with all required runtime dependencies and starts +# a collectd container linked to the database container to allow testing. + +# By default, MariaDB/MySQL port is not exposed to the development host, +# since collectd connects using a hostname defined via container link. +mysql: + image: mariadb + environment: + - MYSQL_ALLOW_EMPTY_PASSWORD=yes +# - MYSQL_ROOT_PASSWORD=root +# - MYSQL_USER=collectd +# - MYSQL_PASSWORD=collectd +# ports: +# - "3306:3306" + +# Collectd service mounts both Python code and plugin configuration from +# current development directory. +# The parent image used for the build just uses collectd's built in CSV +# plugin with output to stdout for debugging. +collectd: + build: . + links: + - mysql + volumes: + - ./mysql.py:/opt/collectd/lib/collectd/plugins/python/mysql.py:ro + - ./mysql.conf:/etc/collectd/conf.d/mysql.conf:ro diff --git a/mysql.conf b/mysql.conf new file mode 100644 index 0000000..2f9b6a4 --- /dev/null +++ b/mysql.conf @@ -0,0 +1,18 @@ + + Globals true + + + ModulePath "/opt/collectd/lib/collectd/plugins/python/" + # Verbose true + + + Import mysql + + Host "mysql" + # Port 3306 + # User "root" # (default: root) + # Password "xxxx" # (default: empty) + # HeartbeatTable "percona.heartbeat" # (if using pt-heartbeat to track slave lag) + # Verbose false # (default: false) + +