golang application that checks a mysql database and creates a series of HTTP responses stored as flat text files that xinetd can return quickly for haproxy health checks.
Install golang 1.3+ and run ./build which will compile to bin/mysql_probe.
A user must be created with the following perms: PROCESS REPLICATION CLIENT like such: CREATE USER mysql_probe@'%' IDENTIFIED BY 'As92rj05UvKK'; GRANT PROCESS,REPLICATION CLIENT ON . TO mysql_probe@'%';
Install fpm and run ./package https://github.com/jordansissel/fpm
Edit /etc/mysqlprobe/config.yaml
mysql_probe --help will provide available options.
Checks can be named and run at configured intervals. Each check can 'roll up' multiple checks and return an alarm if any of the checks fail.
These options apply to an entire instance of mysql_probe. host: hostname to connect to user: user to login to mysql with pass: password to login to mysql with interval: seconds to wait before rerunning this check. This is calculated as starting when the previous check has finished to prevent pileups.
name: display name of this check. must be unique. type: required check name result_files: a list of files to place this result as http responses in text
Checks that replication is not delayed over configured seconds.
max_delay: in seconds, if replication delayed > this number, consider check failed.
Count the existing connections to this server and fail if connection count is too great.
max_connections: if there are more than this many connections to the server, fail
Run a query that returns a number and compare the results
query: query to run fail_if_gt: compare the numeric result of query and fail if the returned value is greater than this number. fail_if_lt: compare the numeric result of query and fail if the returned value is less than this number.
- Build checks with completely hardcoded configuration to check localhost.
- Build configuration parser so this app does not need to be recompiled every time config changes.
- Build rollup checks into configuration.
Check config.go for hardcoded values, host, username, password. Run replcation_delay check and output to /var/run/mysql_probe/replcation_delay.http.txt Run connection_count check and output to /var/run/mysql_probe/connection_count.http.txt
A dockerfile is available in docker/test for spinning up an instance of this app.
TOOD: Add an example haproxy config using these checks to build a resilient failover configuration.
TODO: Add an example of using xinetd to return these http txt files as http requests.
Copyright 2014 Derek Volker
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.