Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker development workflow #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions mysql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<LoadPlugin python>
Globals true
</LoadPlugin>
<Plugin python>
ModulePath "/opt/collectd/lib/collectd/plugins/python/"
# Verbose true
</Plugin>
<Plugin python>
Import mysql
<Module 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)
</Module>
</Plugin>